Search in sources :

Example 46 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyPetIdPath.

private void verifyPetIdPath(JsonMapObject paths) {
    // /pet/{petId}
    JsonMapObject pet = paths.getJsonMapProperty("/pet/{petId}");
    assertEquals(3, pet.size());
    verifyPetIdPathPost(pet);
    verifyPetIdPathGet(pet);
    verifyPetIdPathDelete(pet);
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 47 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyUserLoginPath.

private void verifyUserLoginPath(JsonMapObject paths) {
    // /user/login
    JsonMapObject user = paths.getJsonMapProperty("/user/login");
    assertEquals(1, user.size());
    verifyUserLoginPathPost(user);
}
Also used : JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 48 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyUserUsernamePathDelete.

private void verifyUserUsernamePathDelete(JsonMapObject user) {
    JsonMapObject usetDelete = user.getJsonMapProperty("delete");
    assertEquals(6, usetDelete.size());
    testCommonVerbPropsExceptSec(usetDelete, "deleteUser");
    List<Map<String, Object>> parameters = usetDelete.getListMapProperty("parameters");
    assertEquals(1, parameters.size());
    JsonMapObject userParam = new JsonMapObject(parameters.get(0));
    verifyUserNameParameter(userParam, "username", "path");
    assertNull(usetDelete.getJsonMapProperty("requestBody"));
    JsonMapObject responses = usetDelete.getJsonMapProperty("responses");
    assertEquals(2, responses.size());
    assertNotNull(responses.getProperty("400"));
    assertNotNull(responses.getProperty("404"));
}
Also used : Map(java.util.Map) JsonMapObject(org.apache.cxf.jaxrs.json.basic.JsonMapObject)

Example 49 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method testConvertFromSwaggerToOpenApi.

@Test
public void testConvertFromSwaggerToOpenApi() {
    OpenApiConfiguration cfg = new OpenApiConfiguration();
    String s = SwaggerToOpenApiConversionUtils.getOpenApiFromSwaggerLoc("/swagger2petShop.json");
    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 50 with JsonMapObject

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

the class SwaggerToOpenApiConversionUtilsTest method verifyUserLoginPathPost.

private void verifyUserLoginPathPost(JsonMapObject user) {
    JsonMapObject userPost = user.getJsonMapProperty("get");
    assertEquals(6, userPost.size());
    testCommonVerbPropsExceptSec(userPost, "loginUser");
    assertNull(userPost.getProperty("requestBody"));
    List<Map<String, Object>> parameters = userPost.getListMapProperty("parameters");
    assertEquals(2, parameters.size());
    verifyUserNameParameter(new JsonMapObject(parameters.get(0)), "username", "query");
    verifyPasswordParameter(new JsonMapObject(parameters.get(1)), "password");
    JsonMapObject responses = userPost.getJsonMapProperty("responses");
    assertEquals(2, responses.size());
    assertNotNull(responses.getJsonMapProperty("400"));
    JsonMapObject okResp = responses.getJsonMapProperty("200");
    assertEquals(3, okResp.size());
    assertNotNull(okResp.getProperty("description"));
    assertNotNull(okResp.getProperty("headers"));
    JsonMapObject content = okResp.getJsonMapProperty("content");
    assertEquals(2, content.size());
    verifySimpleStringContent(content, "application/json");
    verifySimpleStringContent(content, "application/xml");
}
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