Search in sources :

Example 21 with JsonMapObject

use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.

the class SwaggerToOpenApiConversionUtilsTest method testDefaultResponse.

private void testDefaultResponse(JsonMapObject json) {
    JsonMapObject responses = json.getJsonMapProperty("responses");
    assertEquals(1, responses.size());
    assertNotNull(responses.getProperty("default"));
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 22 with JsonMapObject

use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.

the class SwaggerToOpenApiConversionUtilsTest method verifyPetPathPost.

private void verifyPetPathPost(JsonMapObject pet, OpenApiConfiguration cfg) {
    JsonMapObject petPost = pet.getJsonMapProperty("post");
    assertEquals(7, petPost.size());
    testCommonVerbProps(petPost, "addPet");
    assertNull(petPost.getProperty("parameters"));
    if (cfg.isCreateRequestBodies()) {
        verifyRequestBodyRef(petPost, "Pet");
    } else {
        JsonMapObject content = verifyRequestBodyContent(petPost);
        assertEquals(2, content.size());
        verifySimpleContent(content, "application/json", "Pet");
        verifySimpleContent(content, "application/xml", "Pet");
    }
    JsonMapObject responses = petPost.getJsonMapProperty("responses");
    assertEquals(1, responses.size());
    assertNotNull(responses.getProperty("405"));
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 23 with JsonMapObject

use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.

the class SwaggerToOpenApiConversionUtilsTest method testConvertFromSwaggerToOpenApiWithRequestBodies.

@Test
public void testConvertFromSwaggerToOpenApiWithRequestBodies() {
    OpenApiConfiguration cfg = new OpenApiConfiguration();
    cfg.setCreateRequestBodies(true);
    String s = SwaggerToOpenApiConversionUtils.getOpenApiFromSwaggerLoc("/swagger2petShop.json", cfg);
    JsonMapObjectReaderWriter readerWriter = new JsonMapObjectReaderWriter();
    JsonMapObject sw3 = readerWriter.fromJsonToJsonObject(s);
    assertEquals("3.0.0", sw3.getStringProperty("openapi"));
    verifyServersProperty(sw3);
    verifyInfoProperty(sw3);
    verifyTagsProperty(sw3);
    verifyPathsProperty(sw3, cfg);
    verifyComponentsProperty(sw3, cfg);
}
Also used : JsonMapObjectReaderWriter(org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter) JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject) Test(org.junit.Test)

Example 24 with JsonMapObject

use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.

the class SwaggerToOpenApiConversionUtilsTest method verifyArrayContent.

private void verifyArrayContent(JsonMapObject contentMap, String mediaType, String modelName) {
    JsonMapObject content = contentMap.getJsonMapProperty(mediaType);
    assertEquals(1, content.size());
    JsonMapObject schema = content.getJsonMapProperty("schema");
    assertEquals(2, schema.size());
    assertEquals("array", schema.getStringProperty("type"));
    JsonMapObject items = schema.getJsonMapProperty("items");
    assertEquals(1, items.size());
    assertEquals("#components/schemas/" + modelName, items.getStringProperty("$ref"));
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 25 with JsonMapObject

use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.

the class SwaggerToOpenApiConversionUtilsTest method verifyStoreInventoryPathGet.

private void verifyStoreInventoryPathGet(JsonMapObject store) {
    JsonMapObject storeGet = store.getJsonMapProperty("get");
    assertEquals(6, storeGet.size());
    testCommonVerbProps(storeGet, "getInventory");
    assertNull(storeGet.getProperty("parameters"));
    assertNull(storeGet.getJsonMapProperty("requestBody"));
    JsonMapObject responses = storeGet.getJsonMapProperty("responses");
    assertEquals(1, responses.size());
    JsonMapObject okResp = responses.getJsonMapProperty("200");
    assertEquals(2, okResp.size());
    assertNotNull(okResp.getProperty("description"));
    JsonMapObject content = okResp.getJsonMapProperty("content");
    assertEquals(1, content.size());
    verifyMapContent(content, "application/json", "integer", "int32");
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Aggregations

JsonMapObject (org.apache.cxf.jaxrs.json.basic.JsonMapObject)63 Map (java.util.Map)23 LinkedHashMap (java.util.LinkedHashMap)5 JsonMapObjectReaderWriter (org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter)5 Test (org.junit.Test)3 LinkedList (java.util.LinkedList)2 IOException (java.io.IOException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 WebClient (org.apache.cxf.jaxrs.client.WebClient)1