use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.
the class SwaggerToOpenApiConversionUtilsTest method verifyMapContent.
private void verifyMapContent(JsonMapObject contentMap, String mediaType, String type, String format) {
JsonMapObject content = contentMap.getJsonMapProperty(mediaType);
assertEquals(1, content.size());
JsonMapObject schema = content.getJsonMapProperty("schema");
assertEquals(2, schema.size());
assertEquals("object", schema.getStringProperty("type"));
JsonMapObject additionalProps = schema.getJsonMapProperty("additionalProperties");
assertEquals(type, additionalProps.getStringProperty("type"));
assertEquals(format, additionalProps.getStringProperty("format"));
}
use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.
the class BigQueryService method getMatchingTexts.
static List<ShakespeareText> getMatchingTexts(WebClient bqClient, ClientAccessToken accessToken, String searchWord, String maxResults) {
bqClient.authorization(accessToken);
String bigQuerySelect = String.format(BQ_SELECT, searchWord);
String bigQueryRequest = String.format(BQ_REQUEST, bigQuerySelect, Integer.parseInt(maxResults));
JsonMapObject jsonMap = bqClient.post(bigQueryRequest, JsonMapObject.class);
List<ShakespeareText> texts = new LinkedList<ShakespeareText>();
List<Map<String, Object>> rows = CastUtils.cast((List<?>) jsonMap.getProperty("rows"));
if (rows != null) {
for (Map<String, Object> row : rows) {
List<Map<String, Object>> fields = CastUtils.cast((List<?>) row.get("f"));
ShakespeareText text = new ShakespeareText((String) fields.get(0).get("v"), (String) fields.get(1).get("v"));
texts.add(text);
}
}
return texts;
}
use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.
the class SwaggerToOpenApiConversionUtils method prepareFormContent.
private static JsonMapObject prepareFormContent(List<JsonMapObject> formList, List<String> mediaTypes) {
String mediaType = StringUtils.isEmpty(mediaTypes) ? "application/x-www-form-urlencoded" : mediaTypes.get(0);
JsonMapObject content = new JsonMapObject();
JsonMapObject formType = new JsonMapObject();
JsonMapObject schema = new JsonMapObject();
schema.setProperty("type", "object");
JsonMapObject props = new JsonMapObject();
for (JsonMapObject prop : formList) {
String name = (String) prop.removeProperty("name");
props.setProperty(name, prop);
if ("file".equals(prop.getProperty("type"))) {
prop.setProperty("type", "string");
if (!prop.containsProperty("format")) {
prop.setProperty("format", "binary");
}
}
}
schema.setProperty("properties", props);
formType.setProperty("schema", schema);
content.setProperty(mediaType, formType);
return content;
}
use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.
the class SwaggerToOpenApiConversionUtils method setPathsProperty.
private static void setPathsProperty(JsonMapObject sw2, JsonMapObject sw3, Map<String, JsonMapObject> requestBodies) {
JsonMapObject sw2Paths = sw2.getJsonMapProperty("paths");
for (Map.Entry<String, Object> sw2PathEntries : sw2Paths.asMap().entrySet()) {
JsonMapObject sw2PathVerbs = new JsonMapObject(CastUtils.cast((Map<?, ?>) sw2PathEntries.getValue()));
for (Map.Entry<String, Object> sw2PathVerbEntries : sw2PathVerbs.asMap().entrySet()) {
JsonMapObject sw2PathVerbProps = new JsonMapObject(CastUtils.cast((Map<?, ?>) sw2PathVerbEntries.getValue()));
prepareRequestBody(sw2PathVerbProps, requestBodies);
prepareResponses(sw2PathVerbProps);
}
}
sw3.setProperty("paths", sw2Paths);
}
use of org.apache.cxf.jaxrs.json.basic.JsonMapObject in project cxf by apache.
the class SwaggerToOpenApiConversionUtilsTest method verifyUserPathPost.
private void verifyUserPathPost(JsonMapObject store, OpenApiConfiguration cfg) {
JsonMapObject userPost = store.getJsonMapProperty("post");
assertEquals(6, userPost.size());
testCommonVerbPropsExceptSec(userPost, "createUser");
assertNull(userPost.getProperty("parameters"));
if (cfg.isCreateRequestBodies()) {
verifyRequestBodyRef(userPost, "User");
} else {
JsonMapObject contentIn = verifyRequestBodyContent(userPost);
assertEquals(1, contentIn.size());
verifySimpleContent(contentIn, "application/json", "User");
}
testDefaultResponse(userPost);
}
Aggregations