Search in sources :

Example 26 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyPetPath.

private void verifyPetPath(JsonMapObject paths, OpenApiConfiguration cfg) {
    // /pet
    JsonMapObject pet = paths.getJsonMapProperty("/pet");
    assertEquals(2, pet.size());
    verifyPetPathPost(pet, cfg);
    verifyPetPathPut(pet, cfg);
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 27 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyStoreOrderIdPathGet.

private void verifyStoreOrderIdPathGet(JsonMapObject store) {
    JsonMapObject storeGet = store.getJsonMapProperty("get");
    assertEquals(6, storeGet.size());
    testCommonVerbPropsExceptSec(storeGet, "getOrderById");
    List<Map<String, Object>> parameters = storeGet.getListMapProperty("parameters");
    assertEquals(1, parameters.size());
    JsonMapObject orderIdParam = new JsonMapObject(parameters.get(0));
    verifyOrderIdParameter(orderIdParam, false);
    assertNull(storeGet.getJsonMapProperty("requestBody"));
    JsonMapObject responses = storeGet.getJsonMapProperty("responses");
    assertEquals(3, responses.size());
    assertNotNull(responses.getProperty("400"));
    assertNotNull(responses.getProperty("404"));
    JsonMapObject okResp = responses.getJsonMapProperty("200");
    assertEquals(2, okResp.size());
    assertNotNull(okResp.getProperty("description"));
    JsonMapObject content = okResp.getJsonMapProperty("content");
    assertEquals(2, content.size());
    verifySimpleContent(content, "application/json", "Order");
    verifySimpleContent(content, "application/xml", "Order");
}
Also used : Map(java.util.Map) JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 28 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyPetFormContent.

private void verifyPetFormContent(JsonMapObject petPost, String mediaType, String firstPropName, String secondPropName) {
    JsonMapObject requestBody = petPost.getJsonMapProperty("requestBody");
    assertEquals(1, requestBody.size());
    JsonMapObject contentMap = requestBody.getJsonMapProperty("content");
    assertEquals(1, contentMap.size());
    JsonMapObject content = contentMap.getJsonMapProperty(mediaType);
    assertEquals(1, content.size());
    JsonMapObject schema = content.getJsonMapProperty("schema");
    assertEquals(2, schema.size());
    assertEquals("object", schema.getStringProperty("type"));
    JsonMapObject props = schema.getJsonMapProperty("properties");
    assertEquals(2, props.size());
    JsonMapObject firstProp = props.getJsonMapProperty(firstPropName);
    assertNotNull(firstProp.getProperty("description"));
    assertEquals("string", firstProp.getProperty("type"));
    JsonMapObject secondProp = props.getJsonMapProperty(secondPropName);
    assertNotNull(secondProp.getProperty("description"));
    assertEquals("string", secondProp.getProperty("type"));
    if ("file".equals(secondPropName)) {
        assertEquals("binary", secondProp.getProperty("format"));
    }
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 29 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifySimpleStringContent.

private void verifySimpleStringContent(JsonMapObject contentMap, String mediaType) {
    JsonMapObject content = contentMap.getJsonMapProperty(mediaType);
    assertEquals(1, content.size());
    JsonMapObject schema = content.getJsonMapProperty("schema");
    assertEquals(1, schema.size());
    assertEquals("string", schema.getStringProperty("type"));
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 30 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyStoreOrderPathPost.

private void verifyStoreOrderPathPost(JsonMapObject store, OpenApiConfiguration cfg) {
    JsonMapObject storePost = store.getJsonMapProperty("post");
    assertEquals(6, storePost.size());
    testCommonVerbPropsExceptSec(storePost, "placeOrder");
    assertNull(storePost.getProperty("parameters"));
    if (cfg.isCreateRequestBodies()) {
        verifyRequestBodyRef(storePost, "Order");
    } else {
        JsonMapObject contentIn = verifyRequestBodyContent(storePost);
        assertEquals(1, contentIn.size());
        verifySimpleContent(contentIn, "application/json", "Order");
    }
    JsonMapObject responses = storePost.getJsonMapProperty("responses");
    assertEquals(2, responses.size());
    assertNotNull(responses.getJsonMapProperty("400"));
    JsonMapObject okResp = responses.getJsonMapProperty("200");
    assertEquals(2, okResp.size());
    assertNotNull(okResp.getProperty("description"));
    JsonMapObject contentOut = okResp.getJsonMapProperty("content");
    assertEquals(2, contentOut.size());
    verifySimpleContent(contentOut, "application/json", "Order");
    verifySimpleContent(contentOut, "application/xml", "Order");
}
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