private static DataShape unifiedJsonSchema(final JsonNode bodySchema, final JsonNode parametersSchema) { if (bodySchema == null && parametersSchema == null) { return DATA_SHAPE_NONE; } final ObjectNode unifiedSchema = newJsonObjectSchema(); final ObjectNode properties = unifiedSchema.putObject("properties"); if (parametersSchema != null) { properties.set("parameters", parametersSchema.get("properties").get("parameters")); } if (bodySchema != null) { properties.set("body", bodySchema); } return new DataShape.Builder()// .name("Request")// .description("API request payload")// .kind(DataShapeKinds.JSON_SCHEMA)// .specification(JsonSchemaHelper.serializeJson(unifiedSchema))// .build(); }
@Override public DataShape createShapeFromResponse(final String specification, final Swagger swagger, final Operation operation) { final Optional<Response> maybeResponse = findResponse(operation); if (!maybeResponse.isPresent()) { return DATA_SHAPE_NONE; } final DataShape response = createShapeFromProperty(specification, maybeResponse.get().getSchema()); if (response.getKind() == DataShapeKinds.NONE) { return response; } return new DataShape.Builder().createFrom(response).name("Response").description("API response payload").build(); }
@Override public DataShape createShapeFromResponse(final String specification, final Swagger swagger, final Operation operation) { final Optional<Response> maybeResponse = findResponse(operation); if (!maybeResponse.isPresent()) { return DATA_SHAPE_NONE; } final Document document = DocumentHelper.createDocument(); final Element schemaSet = document.addElement("d:SchemaSet", SCHEMA_SET_NS); schemaSet.addNamespace(XmlSchemaHelper.XML_SCHEMA_PREFIX, XmlSchemaHelper.XML_SCHEMA_NS); final Map<String, SchemaPrefixAndElement> moreSchemas = new HashMap<>(); final Element bodySchema = createResponseBodySchema(swagger, operation, moreSchemas); if (bodySchema == null) { return DATA_SHAPE_NONE; } schemaSet.add(bodySchema.detach()); if (!moreSchemas.isEmpty()) { final Element additionalSchemas = schemaSet.addElement("d:AdditionalSchemas"); moreSchemas.values().forEach(e -> additionalSchemas.add(e.schema.detach())); } final String xmlSchemaSet = serialize(document); return new DataShape.Builder()// .name("Response")// .description("API response payload")// .kind(DataShapeKinds.XML_SCHEMA)// .specification(xmlSchemaSet)// .build(); }
.description("API request payload")//