private void buildConsumesSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { List<String> consumes = operation.getOperation().getConsumes(); if (CollectionUtils.isNotEmpty(consumes)) { consumesComponent.apply(markupDocBuilder, ConsumesComponent.parameters(consumes, getSectionTitleLevel())); } }
protected String[] updateOperationConsumes(String[] parentConsumes, String[] apiConsumes, Operation operation) { if (parentConsumes != null) { Set<String> both = new LinkedHashSet<>(Arrays.asList(apiConsumes)); both.addAll(Arrays.asList(parentConsumes)); if (operation.getConsumes() != null) { both.addAll(operation.getConsumes()); } apiConsumes = both.toArray(new String[both.size()]); } return apiConsumes; }
private Parameter replaceArrayModelForOctetStream(Operation operation, Parameter parameter) { if (parameter instanceof BodyParameter && operation.getConsumes() != null && operation.getConsumes().contains("application/octet-stream")) { BodyParameter bodyParam = (BodyParameter) parameter; Model schema = bodyParam.getSchema(); if (schema instanceof ArrayModel) { ArrayModel arrayModel = (ArrayModel) schema; Property items = arrayModel.getItems(); if (items != null && items.getFormat() == "byte" && items.getType() == "string") { ModelImpl model = new ModelImpl(); model.setFormat("byte"); model.setType("string"); bodyParam.setSchema(model); } } } return parameter; }
protected void updateOperation(String[] apiConsumes, String[] apiProduces, Map<String, Tag> tags, List<SecurityRequirement> securities, Operation operation) { if (operation == null) { return; } if (operation.getConsumes() == null) { for (String mediaType : apiConsumes) { operation.consumes(mediaType); } } if (operation.getProduces() == null) { for (String mediaType : apiProduces) { operation.produces(mediaType); } } if (operation.getTags() == null) { for (String tagString : tags.keySet()) { operation.tag(tagString); } } for (SecurityRequirement security : securities) { operation.security(security); } }
private static void safeAddConsumes(final Operation op, final String mediaType) { if (((op.getConsumes() == null) || (!op.getConsumes().contains(mediaType)))) { op.addConsumes(mediaType); } }
private List<String> buildHeaders( Swagger swagger, Map.Entry<String, Path> path, Map.Entry<HttpMethod, Operation> operation ) { List<String> headers = new ArrayList<>(); headers.add( operation.getKey().toString() + " " + swagger.getBasePath() + path.getKey() + " HTTP/1.1"); headers.add("Host: " + swagger.getHost().split(":")[0]); if (CollectionUtils.isNotEmpty(operation.getValue().getProduces())) { headers.add("Accept: " + String.join(",", operation.getValue().getProduces())); } else if (CollectionUtils.isNotEmpty(swagger.getProduces())) { headers.add("Accept: " + String.join(",", swagger.getProduces())); } if (CollectionUtils.isNotEmpty(operation.getValue().getConsumes())) { headers.add("Content-Type: " + String.join(",", operation.getValue().getConsumes())); } else if (CollectionUtils.isNotEmpty(swagger.getConsumes())) { headers.add("Content-Type: " + String.join(",", swagger.getConsumes())); } return headers; }
List<String> getExpectedConsumes(Operation op) { return getListWithFallback(op.getConsumes(), expected.getConsumes()); }
List<String> getActualConsumes(Operation op) { return getListWithFallback(op.getConsumes(), actual.getConsumes()); }
private void buildConsumesSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { List<String> consumes = operation.getOperation().getConsumes(); if (CollectionUtils.isNotEmpty(consumes)) { consumesComponent.apply(markupDocBuilder, ConsumesComponent.parameters(consumes, getSectionTitleLevel())); } }
@Override public DataShape createShapeFromRequest(final ObjectNode json, final Swagger swagger, final Operation operation) { if (supports(APPLICATION_JSON, swagger.getConsumes(), operation.getConsumes())) { return JSON.createShapeFromRequest(json, swagger, operation); } else if (supports(APPLICATION_XML, swagger.getConsumes(), operation.getConsumes())) { return XML.createShapeFromRequest(json, swagger, operation); } else { // most likely a body-less request, i.e. only with parameters, we'll // use JSON to define those parameters return JSON.createShapeFromRequest(json, swagger, operation); } }
@Override public DataShape createShapeFromRequest(final String specification, final Swagger swagger, final Operation operation) { if (supports(APPLICATION_JSON, swagger.getConsumes(), operation.getConsumes())) { return JSON.createShapeFromRequest(specification, swagger, operation); } else if (supports(APPLICATION_XML, swagger.getConsumes(), operation.getConsumes())) { return XML.createShapeFromRequest(specification, swagger, operation); } else { // most likely a body-less request, i.e. only with parameters, we'll // use JSON to define those parameters return JSON.createShapeFromRequest(specification, swagger, operation); } }
@Override public DataShape createShapeFromRequest(final ObjectNode json, final Swagger swagger, final Operation operation) { if (supports(APPLICATION_JSON, swagger.getConsumes(), operation.getConsumes())) { return JSON.createShapeFromRequest(json, swagger, operation); } else if (supports(APPLICATION_XML, swagger.getConsumes(), operation.getConsumes())) { return XML.createShapeFromRequest(json, swagger, operation); } else { // most likely a body-less request, i.e. only with parameters, we'll // use JSON to define those parameters return JSON.createShapeFromRequest(json, swagger, operation); } }
final String determinedProducers = determineOption(swagger.getConsumes(), operation.getConsumes(), component.getProduces(), produces);
@Override public void operation(HttpMethod httpMethod, Operation operation) { if (operation.getConsumes() == null) { operation.setConsumes(model.getConsumes()); } if (operation.getProduces() == null) { operation.setProduces(model.getProduces()); } } });
private static void configureRoute(Route route, String serviceId, Operation operation, EventBus eventBus, Function<RoutingContext, DeliveryOptions> configureMessage) { Optional.ofNullable(operation.getConsumes()).ifPresent(consumes -> consumes.forEach(route::consumes)); Optional.ofNullable(operation.getProduces()).ifPresent(produces -> produces.forEach(route::produces));
String consumes = getTypes(nvl(operation.getConsumes(), swagger.getConsumes()), getPreferredConsumes()); String name = operation.getOperationId(); if (name == null) {
apiResourceBuilder.produces(produceSeparatedString); List<String> consumesList = operation.getConsumes(); if (consumesList != null) { String consumesSeparatedString = "\"";
apiResourceBuilder.produces(produceSeparatedString); List<String> consumesList = operation.getConsumes(); if (consumesList != null) { String consumesSeparatedString = "\"";
logger.info("HTTP Method: " + operation.getKey().toString()); logger.info("Schemes: " + operation.getValue().getSchemes()); logger.info("Consumes: " + operation.getValue().getConsumes()); logger.info("Produces: " + operation.getValue().getProduces()); logger.info("Parameters: " + operation.getValue().getParameters());
if ("post".equalsIgnoreCase(httpMethod) && operation.getConsumes() == null) { operation.addConsumes("application/x-www-form-urlencoded");