use of io.swagger.v3.oas.models.media.Schema in project activityinfo by bedatadriven.
the class FormResource method getXlsForm.
@GET
@NoCache
@Path("form.xls")
@Operation(summary = "Get a form's schema as an XLSForm")
public Response getXlsForm() {
assertVisible(formId);
final XlsFormBuilder xlsForm = new XlsFormBuilder(backend.getStorage());
xlsForm.build(formId);
StreamingOutput output = xlsForm::write;
return Response.ok(output, "application/vnd.ms-excel").build();
}
use of io.swagger.v3.oas.models.media.Schema in project syncope by apache.
the class SyncopeOpenApiCustomizer method customize.
@Override
public OpenAPIConfiguration customize(final OpenAPIConfiguration configuration) {
Map<String, Header> headers = new LinkedHashMap<>();
headers.put(RESTHeaders.ERROR_CODE, new Header().schema(new Schema<>().type("string")).description("Error code"));
headers.put(RESTHeaders.ERROR_INFO, new Header().schema(new Schema<>().type("string")).description("Error message"));
Content content = new Content();
content.addMediaType(javax.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType().schema(new Schema<ErrorTO>()));
content.addMediaType(javax.ws.rs.core.MediaType.APPLICATION_XML, new MediaType().schema(new Schema<ErrorTO>()));
configuration.getOpenAPI().getComponents().addResponses("400", new ApiResponse().description("An error occurred; HTTP status code can vary depending on the actual error: " + "400, 403, 404, 409, 412").headers(headers).content(content));
return super.customize(configuration);
}
use of io.swagger.v3.oas.models.media.Schema in project syncope by apache.
the class SyncopeOpenApiCustomizer method addParameters.
@Override
protected void addParameters(final List<Parameter> parameters) {
if (domains == null) {
domains = new ArrayList<>(ApplicationContextProvider.getApplicationContext().getBean(DomainsHolder.class).getDomains().keySet());
}
Optional<Parameter> domainHeaderParameter = parameters.stream().filter(parameter -> parameter instanceof HeaderParameter && RESTHeaders.DOMAIN.equals(parameter.getName())).findFirst();
if (!domainHeaderParameter.isPresent()) {
HeaderParameter parameter = new HeaderParameter();
parameter.setName(RESTHeaders.DOMAIN);
parameter.setRequired(true);
Schema<String> schema = new Schema<>();
schema.setType("string");
schema.setEnum(domains);
schema.setDefault(SyncopeConstants.MASTER_DOMAIN);
parameter.setSchema(schema);
parameters.add(parameter);
}
}
use of io.swagger.v3.oas.models.media.Schema in project vertx-web by vert-x3.
the class OpenApi3Utils method replaceRef.
private static void replaceRef(ObjectNode n, ObjectNode root, OpenAPI oas) {
/**
* If a ref is found, the structure of the schema is circular. The oas parser don't solve circular refs.
* So I bundle the schema:
* 1. I update the ref field with a #/definitions/schema_name uri
* 2. If #/definitions/schema_name is empty, I solve it
*/
String oldRef = n.get("$ref").asText();
Matcher m = COMPONENTS_REFS_MATCHER.matcher(oldRef);
if (m.lookingAt()) {
String schemaName = m.group(1);
String newRef = m.replaceAll(COMPONENTS_REFS_SUBSTITUTION);
n.remove("$ref");
n.put("$ref", newRef);
if (!root.has("definitions") || !root.get("definitions").has(schemaName)) {
Schema s = oas.getComponents().getSchemas().get(schemaName);
ObjectNode schema = ObjectMapperFactory.createJson().convertValue(s, ObjectNode.class);
// We need to search inside for other refs
if (!root.has("definitions")) {
ObjectNode definitions = JsonNodeFactory.instance.objectNode();
definitions.set(schemaName, schema);
root.putObject("definitions");
} else {
((ObjectNode) root.get("definitions")).set(schemaName, schema);
}
walkAndSolve(schema, root, oas);
}
} else
throw new RuntimeException("Wrong ref! " + oldRef);
}
Aggregations