Search in sources :

Example 41 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyComponentsProperty.

private void verifyComponentsProperty(JsonMapObject sw3, OpenApiConfiguration cfg) {
    JsonMapObject comps = sw3.getJsonMapProperty("components");
    assertEquals(3, comps.size());
    JsonMapObject requestBodies = comps.getJsonMapProperty("requestBodies");
    if (cfg.isCreateRequestBodies()) {
        assertEquals(4, requestBodies.size());
        // UserArray
        JsonMapObject userArrayContent = verifyRequestBodyContent(requestBodies, "UserArray");
        assertEquals(1, userArrayContent.size());
        verifyArrayContent(userArrayContent, "application/json", "User");
        // Pet
        JsonMapObject petContent = verifyRequestBodyContent(requestBodies, "Pet");
        assertEquals(2, petContent.size());
        verifySimpleContent(petContent, "application/json", "Pet");
        verifySimpleContent(petContent, "application/xml", "Pet");
        // User
        JsonMapObject userContent = verifyRequestBodyContent(requestBodies, "User");
        assertEquals(1, userContent.size());
        verifySimpleContent(userContent, "application/json", "User");
        // Order
        JsonMapObject orderContent = verifyRequestBodyContent(requestBodies, "Order");
        assertEquals(1, orderContent.size());
        verifySimpleContent(orderContent, "application/json", "Order");
    } else {
        assertEquals(0, requestBodies.size());
    }
    assertNotNull(comps.getJsonMapProperty("schemas"));
    assertNotNull(comps.getJsonMapProperty("securitySchemes"));
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 42 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyRequestBodyContent.

private JsonMapObject verifyRequestBodyContent(JsonMapObject json, String propName) {
    JsonMapObject requestBody = json.getJsonMapProperty(propName);
    assertEquals(3, requestBody.size());
    assertNotNull(requestBody.getProperty("description"));
    assertTrue(requestBody.getBooleanProperty("required"));
    return requestBody.getJsonMapProperty("content");
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 43 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyPetPathPut.

private void verifyPetPathPut(JsonMapObject pet, OpenApiConfiguration cfg) {
    JsonMapObject petPut = pet.getJsonMapProperty("put");
    assertEquals(7, petPut.size());
    testCommonVerbProps(petPut, "updatePet");
    assertNull(petPut.getProperty("parameters"));
    if (cfg.isCreateRequestBodies()) {
        verifyRequestBodyRef(petPut, "Pet");
    } else {
        JsonMapObject content = verifyRequestBodyContent(petPut);
        assertEquals(2, content.size());
        verifySimpleContent(content, "application/json", "Pet");
        verifySimpleContent(content, "application/xml", "Pet");
    }
    JsonMapObject responses = petPut.getJsonMapProperty("responses");
    assertEquals(3, responses.size());
    assertNotNull(responses.getProperty("400"));
    assertNotNull(responses.getProperty("404"));
    assertNotNull(responses.getProperty("405"));
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 44 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyOrderIdParameter.

private void verifyOrderIdParameter(JsonMapObject param, boolean minOnly) {
    assertEquals("orderId", param.getProperty("name"));
    assertEquals("path", 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(minOnly ? 3 : 4, schema.size());
    assertEquals("integer", schema.getProperty("type"));
    assertNotNull(schema.getProperty("minimum"));
    if (!minOnly) {
        assertNotNull(schema.getProperty("maximum"));
    }
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 45 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyPetIdParameter.

private void verifyPetIdParameter(JsonMapObject param) {
    assertEquals("petId", param.getProperty("name"));
    assertEquals("path", 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(2, schema.size());
    assertEquals("integer", schema.getProperty("type"));
    assertEquals("int64", schema.getProperty("format"));
}
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