private static DataShape unifiedJsonSchema(final String name, final String description, final ObjectNode bodySchema, final ObjectNode parametersSchema) { if (bodySchema == null && parametersSchema == null) { return DATA_SHAPE_NONE; } final ObjectNode unifiedSchema = JsonSchemaHelper.newJsonObjectSchema(); unifiedSchema.put("$id", "io:syndesis:wrapped"); final ObjectNode properties = unifiedSchema.putObject("properties"); if (parametersSchema != null) { properties.remove(PROPERTIES_TO_REMOVE_ON_MERGE); properties.set("parameters", parametersSchema.get("properties").get("parameters")); } if (bodySchema != null) { bodySchema.remove(PROPERTIES_TO_REMOVE_ON_MERGE); properties.set("body", bodySchema); } return new DataShape.Builder()// .name(name)// .description(description)// .kind(DataShapeKinds.JSON_SCHEMA)// .specification(JsonSchemaHelper.serializeJson(unifiedSchema))// .build(); }
@Override public DataShape createShapeFromResponse(final ObjectNode json, final Swagger swagger, final Operation operation) { final Optional<Response> maybeResponse = findResponse(operation); if (!maybeResponse.isPresent()) { return DATA_SHAPE_NONE; } final Response response = maybeResponse.get(); final Model responseSchema = response.getResponseSchema(); final String description = response.getDescription(); final JsonNode schema = createSchemaFromModel(json, description, responseSchema); String schemaString; try { schemaString = Json.writer().writeValueAsString(schema); } catch (final JsonProcessingException e) { throw new IllegalStateException("Unable to serialize given JSON specification in response schema: " + schema, e); } return new DataShape.Builder().kind(DataShapeKinds.JSON_SCHEMA).name("Response").description("API response payload") .specification(schemaString).build(); }
.type("io.syndesis.connector.fhir.FhirReadMessageModel") .description("FHIR " + actionId) .name(actionId).build(), new DataShape.Builder().kind(DataShapeKinds.XML_SCHEMA)// .type(type) .description("FHIR " + type) .specification(specification) .name(type).build()); } else { return new SyndesisMetadata( .description("FHIR " + type) .specification(specification) .name(type).build(), new DataShape.Builder().kind(DataShapeKinds.JAVA)// .type("ca.uhn.fhir.rest.api.MethodOutcome") .description("FHIR " + actionId) .name(actionId).build());
.name("Contact")// .description("Salesforce Contact")// .specification(
.name("Request")// .description("API request payload")//
.name("Request")// .description("API request payload")//
@Override public DataShape createShapeFromResponse(final ObjectNode json, 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 = XmlSchemaHelper.serialize(document); return new DataShape.Builder()// .name("Response")// .description("API response payload")// .kind(DataShapeKinds.XML_SCHEMA)// .specification(xmlSchemaSet)// .build(); }
@Override public DataShape createShapeFromResponse(final ObjectNode json, 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(); }
private static DataShape unifiedJsonSchema(final ObjectNode bodySchema, final ObjectNode parametersSchema) { if (bodySchema == null && parametersSchema == null) { return DATA_SHAPE_NONE; } final ObjectNode unifiedSchema = JsonSchemaHelper.newJsonObjectSchema(); final ObjectNode properties = unifiedSchema.putObject("properties"); if (parametersSchema != null) { properties.remove(PROPERTIES_TO_REMOVE_ON_MERGE); properties.set("parameters", parametersSchema.get("properties").get("parameters")); } if (bodySchema != null) { bodySchema.remove(PROPERTIES_TO_REMOVE_ON_MERGE); properties.set("body", bodySchema); } return new DataShape.Builder()// .name("Request")// .description("API request payload")// .kind(DataShapeKinds.JSON_SCHEMA)// .specification(JsonSchemaHelper.serializeJson(unifiedSchema))// .build(); }