Search in sources :

Example 1 with InfoDef

use of com.devonfw.cobigen.openapiplugin.model.InfoDef in project cobigen by devonfw.

the class OpenAPIInputReader method extractInfo.

/**
 * @param openApi document root
 * @return an object of {@link InfoDef}
 */
private InfoDef extractInfo(OpenApi3 openApi) {
    InfoDef info = new InfoDef();
    Info inf = openApi.getInfo();
    info.setDescription(inf.getDescription());
    info.setTitle(inf.getTitle());
    return info;
}
Also used : InfoDef(com.devonfw.cobigen.openapiplugin.model.InfoDef) Info(com.reprezen.kaizen.oasparser.model3.Info)

Example 2 with InfoDef

use of com.devonfw.cobigen.openapiplugin.model.InfoDef in project cobigen by devonfw.

the class OpenAPIInputReaderTest method testRetrieveHeaderInfo.

@Test
public void testRetrieveHeaderInfo() throws Exception {
    List<Object> inputObjects = getInputs("two-components.yaml");
    for (Object o : inputObjects) {
        if (isEntityDef(o)) {
            EntityDef entityDef = (EntityDef) o;
            HeaderDef header = entityDef.getHeader();
            InfoDef info = header.getInfo();
            assertThat(info.getDescription()).isEqualTo("Example of a API definition");
            assertThat(info.getTitle()).isEqualTo("Devon Example");
            List<ServerDef> servers = header.getServers();
            assertThat(servers).hasSize(1);
            ServerDef server = servers.get(0);
            assertThat(server.getDescription()).isEqualTo("Just some data");
            assertThat(server.getURI()).isEqualTo("https://localhost:8081/server/services/rest");
        }
    }
}
Also used : HeaderDef(com.devonfw.cobigen.openapiplugin.model.HeaderDef) InfoDef(com.devonfw.cobigen.openapiplugin.model.InfoDef) EntityDef(com.devonfw.cobigen.openapiplugin.model.EntityDef) ServerDef(com.devonfw.cobigen.openapiplugin.model.ServerDef) Test(org.junit.Test)

Aggregations

InfoDef (com.devonfw.cobigen.openapiplugin.model.InfoDef)2 EntityDef (com.devonfw.cobigen.openapiplugin.model.EntityDef)1 HeaderDef (com.devonfw.cobigen.openapiplugin.model.HeaderDef)1 ServerDef (com.devonfw.cobigen.openapiplugin.model.ServerDef)1 Info (com.reprezen.kaizen.oasparser.model3.Info)1 Test (org.junit.Test)1