RequestBody requestBody = optionalRequestBody.get(); if (StringUtils.isBlank(requestBody.get$ref()) && (requestBody.getContent() == null || requestBody.getContent().isEmpty())) { if (requestBodyParameter.getSchema() != null) { Content content = processContent(requestBody.getContent(), requestBodyParameter.getSchema(), methodConsumes, classConsumes); requestBody.setContent(content); requestBody.getContent() != null && !requestBody.getContent().isEmpty()) { if (requestBodyParameter.getSchema() != null) { for (MediaType mediaType : requestBody.getContent().values()) { if (mediaType.getSchema() == null) { if (requestBodyParameter.getSchema() == null) {
operation.requestBody(parentRequestBody); } else { Content content = operation.getRequestBody().getContent(); if (content == null) { content = parentRequestBody.getContent(); operation.getRequestBody().setContent(content); } else if (parentRequestBody.getContent() != null){ for (String parentMediaType: parentRequestBody.getContent().keySet()) { if (content.get(parentMediaType) == null) { content.addMediaType(parentMediaType, parentRequestBody.getContent().get(parentMediaType));
Operation op = ops.get(key); if (op.getRequestBody() != null) { addContentSchemaRef(op.getRequestBody().getContent(), referencedDefinitions);
protected String getContentType(RequestBody requestBody) { if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) { return null; } return new ArrayList<>(requestBody.getContent().keySet()).get(0); }
protected String getContentType(RequestBody requestBody) { if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) { return null; } return new ArrayList<>(requestBody.getContent().keySet()).get(0); }
protected String getContentType(RequestBody requestBody) { if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) { return null; } return new ArrayList<>(requestBody.getContent().keySet()).get(0); }
/** * Return the first defined Schema for a RequestBody * * @param requestBody request body of the operation * @return firstSchema */ public static Schema getSchemaFromRequestBody(RequestBody requestBody) { return getSchemaFromContent(requestBody.getContent()); }
private Optional<Pair<String, MediaType>> findApiMediaTypeForRequest(final Request request, @Nullable final RequestBody apiRequestBodyDefinition) { if (apiRequestBodyDefinition == null || apiRequestBodyDefinition.getContent() == null) { return Optional.empty(); } final Optional<String> mostSpecificMatch = findMostSpecificMatch(request, apiRequestBodyDefinition.getContent().keySet()); if (!mostSpecificMatch.isPresent()) { return Optional.empty(); } final MediaType mediaType = apiRequestBodyDefinition.getContent().get(mostSpecificMatch.get()); return Optional.of(Pair.of(mostSpecificMatch.get(), mediaType)); }
public static Set<String> getConsumesInfo(OpenAPI openAPI, Operation operation) { RequestBody requestBody = ModelUtils.getReferencedRequestBody(openAPI, operation.getRequestBody()); if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) { return Collections.emptySet(); // return empty set } return requestBody.getContent().keySet(); }
protected Schema getSchemaFromBody(RequestBody requestBody) { String contentType = new ArrayList<>(requestBody.getContent().keySet()).get(0); MediaType mediaType = requestBody.getContent().get(contentType); return mediaType.getSchema(); }
protected Schema getSchemaFromBody(RequestBody requestBody) { String contentType = new ArrayList<>(requestBody.getContent().keySet()).get(0); MediaType mediaType = requestBody.getContent().get(contentType); return mediaType.getSchema(); }
protected void updateLocalRefs(RequestBody body, String pathRef) { if(body.getContent() != null) { Map<String, MediaType> content = body.getContent(); for (String key: content.keySet()) { MediaType mediaType = content.get(key); if (mediaType.getSchema() != null) { updateLocalRefs(mediaType.getSchema(), pathRef); } } }else if(body.get$ref() != null){ } }
protected void updateLocalRefs(RequestBody body, String pathRef) { if(body.getContent() != null) { Map<String, MediaType> content = body.getContent(); for (String key: content.keySet()) { MediaType mediaType = content.get(key); if (mediaType.getSchema() != null) { updateLocalRefs(mediaType.getSchema(), pathRef); } } }else if(body.get$ref() != null){ } }
protected void updateLocalRefs(RequestBody body, String pathRef) { if(body.getContent() != null) { Map<String, MediaType> content = body.getContent(); for (String key: content.keySet()) { MediaType mediaType = content.get(key); if (mediaType.getSchema() != null) { updateLocalRefs(mediaType.getSchema(), pathRef); } } }else if(body.get$ref() != null){ } }
@Override public Request transform(RequestBody from) { Set<Map.Entry<String, io.swagger.v3.oas.models.media.MediaType>> entries = from.getContent().entrySet(); Map<MediaType, Schema> mediaTypes = entries.stream().collect(toMap(e -> new MediaType(e.getKey()), e -> mediaTypeTransformer.transform(e.getValue()))); return new Request(mediaTypes); } }
protected Set<String> getConsumesInfo(Operation operation) { if(operation.getRequestBody() == null || operation.getRequestBody().getContent() == null || operation.getRequestBody().getContent().isEmpty()) { return null; } return operation.getRequestBody().getContent().keySet(); }
protected Set<String> getConsumesInfo(Operation operation) { if(operation.getRequestBody() == null || operation.getRequestBody().getContent() == null || operation.getRequestBody().getContent().isEmpty()) { return null; } return operation.getRequestBody().getContent().keySet(); }
@Nonnull private Collection<String> getConsumes(final ApiOperation apiOperation) { if (apiOperation.getOperation().getRequestBody() == null) { return emptyList(); } return defaultIfNull(apiOperation.getOperation().getRequestBody().getContent().keySet(), emptySet()); }
private boolean containsFormContentType(RequestBody body) { if (body == null) { return false; } final Content content = body.getContent(); if (content == null || content.isEmpty()) { return false; } return content.get("application/x-www-form-urlencoded") != null || content.get("multipart/form-data") != null; }
private boolean containsFormContentType(RequestBody body) { if (body == null) { return false; } final Content content = body.getContent(); if (content == null || content.isEmpty()) { return false; } return content.get("application/x-www-form-urlencoded") != null || content.get("multipart/form-data") != null; }