Java Code Examples for io.swagger.v3.oas.models.responses.ApiResponse#getHeaders()
The following examples show how to use
io.swagger.v3.oas.models.responses.ApiResponse#getHeaders() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OperationBuilder.java From springdoc-openapi with Apache License 2.0 | 5 votes |
/** * Calculate header. * * @param apiResponseObject the api response object */ private void calculateHeader(ApiResponse apiResponseObject) { Map<String, Header> headers = apiResponseObject.getHeaders(); if (!CollectionUtils.isEmpty(headers)) { for (Map.Entry<String, Header> entry : headers.entrySet()) { Header header = entry.getValue(); if (header.getSchema() == null) { Schema<?> schema = AnnotationsUtils.resolveSchemaFromType(String.class, null, null); header.setSchema(schema); entry.setValue(header); } } } }
Example 2
Source File: OASParserUtil.java From carbon-apimgt with Apache License 2.0 | 5 votes |
private static void setRefOfApiResponseHeaders(ApiResponses responses, SwaggerUpdateContext context) { if (responses != null) { for (ApiResponse response : responses.values()) { Map<String, Header> headers = response.getHeaders(); if (headers != null) { for (Header header : headers.values()) { Content content = header.getContent(); extractReferenceFromContent(content, context); } } } } }
Example 3
Source File: ResponseHeadersKeysValidator.java From servicecomb-toolkit with Apache License 2.0 | 4 votes |
@Override protected Map<String, ?> getMapProperty(ApiResponse oasObject) { return oasObject.getHeaders(); }
Example 4
Source File: ResponseHeadersValuesValidator.java From servicecomb-toolkit with Apache License 2.0 | 4 votes |
@Override protected Map<String, Header> getMapProperty(ApiResponse components) { return components.getHeaders(); }
Example 5
Source File: ResponseHeadersDiffValidator.java From servicecomb-toolkit with Apache License 2.0 | 4 votes |
@Override protected Map<String, Header> getMapProperty(ApiResponse components) { return components.getHeaders(); }
Example 6
Source File: ModelUtils.java From openapi-generator with Apache License 2.0 | 4 votes |
private static void visitPathItem(PathItem pathItem, OpenAPI openAPI, OpenAPISchemaVisitor visitor, List<String> visitedSchemas) { List<Operation> allOperations = pathItem.readOperations(); if (allOperations != null) { for (Operation operation : allOperations) { //Params: visitParameters(openAPI, operation.getParameters(), visitor, visitedSchemas); //RequestBody: RequestBody requestBody = getReferencedRequestBody(openAPI, operation.getRequestBody()); if (requestBody != null) { visitContent(openAPI, requestBody.getContent(), visitor, visitedSchemas); } //Responses: if (operation.getResponses() != null) { for (ApiResponse r : operation.getResponses().values()) { ApiResponse apiResponse = getReferencedApiResponse(openAPI, r); if (apiResponse != null) { visitContent(openAPI, apiResponse.getContent(), visitor, visitedSchemas); if (apiResponse.getHeaders() != null) { for (Entry<String, Header> e : apiResponse.getHeaders().entrySet()) { Header header = getReferencedHeader(openAPI, e.getValue()); if (header.getSchema() != null) { visitSchema(openAPI, header.getSchema(), e.getKey(), visitedSchemas, visitor); } visitContent(openAPI, header.getContent(), visitor, visitedSchemas); } } } } } //Callbacks: if (operation.getCallbacks() != null) { for (Callback c : operation.getCallbacks().values()) { Callback callback = getReferencedCallback(openAPI, c); if (callback != null) { for (PathItem p : callback.values()) { visitPathItem(p, openAPI, visitor, visitedSchemas); } } } } } } //Params: visitParameters(openAPI, pathItem.getParameters(), visitor, visitedSchemas); }
Example 7
Source File: ExternalRefProcessor.java From swagger-parser with Apache License 2.0 | 4 votes |
public String processRefToExternalResponse(String $ref, RefFormat refFormat) { String renamedRef = cache.getRenamedRef($ref); if(renamedRef != null) { return renamedRef; } final ApiResponse response = cache.loadRef($ref, refFormat, ApiResponse.class); String newRef; if (openAPI.getComponents() == null) { openAPI.setComponents(new Components()); } Map<String, ApiResponse> responses = openAPI.getComponents().getResponses(); if (responses == null) { responses = new LinkedHashMap<>(); } final String possiblyConflictingDefinitionName = computeDefinitionName($ref); ApiResponse existingResponse = responses.get(possiblyConflictingDefinitionName); if (existingResponse != null) { LOGGER.debug("A model for " + existingResponse + " already exists"); if(existingResponse.get$ref() != null) { // use the new model existingResponse = null; } } newRef = possiblyConflictingDefinitionName; cache.putRenamedRef($ref, newRef); if(response != null) { if(response.getContent() != null){ processRefContent(response.getContent(), $ref); } if(response.getHeaders() != null){ processRefHeaders(response.getHeaders(), $ref); } if(response.getLinks() != null){ processRefLinks(response.getLinks(), $ref); } } return newRef; }
Example 8
Source File: ResponseProcessor.java From swagger-parser with Apache License 2.0 | 4 votes |
public void processResponse(ApiResponse response) { if (response.get$ref() != null){ processReferenceResponse(response); } Schema schema = null; if(response.getContent() != null){ Map<String,MediaType> content = response.getContent(); for( String mediaName : content.keySet()) { MediaType mediaType = content.get(mediaName); if(mediaType.getSchema()!= null) { schema = mediaType.getSchema(); if (schema != null) { schemaProcessor.processSchema(schema); } } if(mediaType.getExamples() != null) { for(Example ex: mediaType.getExamples().values()){ exampleProcessor.processExample(ex); } } } } if (response.getHeaders() != null){ Map<String,Header> headers = response.getHeaders(); for(String headerName : headers.keySet()){ Header header = headers.get(headerName); headerProcessor.processHeader(header); } } if (response.getLinks() != null){ Map<String,Link> links = response.getLinks(); for(String linkName : links.keySet()){ Link link = links.get(linkName); linkProcessor.processLink(link); } } }
Example 9
Source File: OperationBuilder.java From springdoc-openapi with Apache License 2.0 | 2 votes |
/** * Is response object boolean. * * @param apiResponseObject the api response object * @return the boolean */ private boolean isResponseObject(ApiResponse apiResponseObject) { return StringUtils.isNotBlank(apiResponseObject.getDescription()) || apiResponseObject.getContent() != null || apiResponseObject.getHeaders() != null; }