Search in sources :

Example 1 with ServerDef

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

the class OpenAPIInputReader method extractServers.

/**
 * @param openApi document root
 * @return list of {@link ServerDef}'s
 */
private List<ServerDef> extractServers(OpenApi3 openApi) {
    List<ServerDef> servers = new LinkedList<>();
    ServerDef serv;
    for (Server server : openApi.getServers()) {
        serv = new ServerDef();
        serv.setDescription(server.getDescription());
        serv.setURI(server.getUrl());
        servers.add(serv);
    }
    return servers;
}
Also used : Server(com.reprezen.kaizen.oasparser.model3.Server) LinkedList(java.util.LinkedList) ServerDef(com.devonfw.cobigen.openapiplugin.model.ServerDef)

Example 2 with ServerDef

use of com.devonfw.cobigen.openapiplugin.model.ServerDef 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

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