Search in sources :

Example 31 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyRequestBodyRef.

private void verifyRequestBodyRef(JsonMapObject json, String refName) {
    JsonMapObject requestBody = json.getJsonMapProperty("requestBody");
    assertEquals(1, requestBody.size());
    assertEquals("#components/requestBodies/" + refName, requestBody.getProperty("$ref"));
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 32 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyStringParameter.

private void verifyStringParameter(JsonMapObject param, String name, String inType) {
    assertEquals(name, param.getProperty("name"));
    assertEquals(inType, param.getProperty("in"));
    assertNull(param.getProperty("type"));
    assertNull(param.getProperty("format"));
    assertNotNull(param.getProperty("description"));
    assertTrue(param.getBooleanProperty("required"));
    JsonMapObject schema = param.getJsonMapProperty("schema");
    assertEquals("password".equals(name) ? 2 : 1, schema.size());
    assertEquals("string", schema.getProperty("type"));
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 33 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyUserUsernamePathGet.

private void verifyUserUsernamePathGet(JsonMapObject user) {
    JsonMapObject userGet = user.getJsonMapProperty("get");
    assertEquals(6, userGet.size());
    testCommonVerbPropsExceptSec(userGet, "getUserByName");
    List<Map<String, Object>> parameters = userGet.getListMapProperty("parameters");
    assertEquals(1, parameters.size());
    JsonMapObject userParam = new JsonMapObject(parameters.get(0));
    verifyUserNameParameter(userParam, "username", "path");
    assertNull(userGet.getProperty("requestBody"));
    JsonMapObject responses = userGet.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", "User");
    verifySimpleContent(content, "application/xml", "User");
}
Also used : Map(java.util.Map) JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 34 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifySimpleContent.

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

Example 35 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyPetIdUploadImagePathPost.

private void verifyPetIdUploadImagePathPost(JsonMapObject pet) {
    JsonMapObject petPost = pet.getJsonMapProperty("post");
    assertEquals(8, petPost.size());
    testCommonVerbProps(petPost, "uploadFile");
    List<Map<String, Object>> parameters = petPost.getListMapProperty("parameters");
    assertEquals(1, parameters.size());
    JsonMapObject pathIdParam = new JsonMapObject(parameters.get(0));
    verifyPetIdParameter(pathIdParam);
    verifyPetFormContent(petPost, "multipart/form-data", "additionalMetadata", "file");
    JsonMapObject responses = petPost.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());
    verifySimpleContent(content, "application/json", "ApiResponse");
}
Also used : Map(java.util.Map) 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