Java Code Examples for io.swagger.v3.oas.models.responses.ApiResponses#put()
The following examples show how to use
io.swagger.v3.oas.models.responses.ApiResponses#put() .
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: DataRestResponseBuilder.java From springdoc-openapi with Apache License 2.0 | 5 votes |
/** * Add response. * * @param requestMethod the request method * @param operationPath the operation path * @param apiResponses the api responses * @param apiResponse the api response */ private void addResponse(RequestMethod requestMethod, String operationPath, ApiResponses apiResponses, ApiResponse apiResponse) { switch (requestMethod) { case GET: addResponse200(apiResponses, apiResponse); if (operationPath.contains("/{id}")) addResponse404(apiResponses); break; case POST: apiResponses.put(String.valueOf(HttpStatus.CREATED.value()), apiResponse.description(HttpStatus.CREATED.getReasonPhrase())); break; case DELETE: addResponse204(apiResponses); addResponse404(apiResponses); break; case PUT: addResponse200(apiResponses, apiResponse); apiResponses.put(String.valueOf(HttpStatus.CREATED.value()), new ApiResponse().content(apiResponse.getContent()).description(HttpStatus.CREATED.getReasonPhrase())); addResponse204(apiResponses); break; case PATCH: addResponse200(apiResponses, apiResponse); addResponse204(apiResponses); break; default: throw new IllegalArgumentException(requestMethod.name()); } }
Example 2
Source File: OpenAPIDeserializer.java From swagger-parser with Apache License 2.0 | 5 votes |
public ApiResponses getResponses(ObjectNode node, String location, ParseResult result, boolean underComponents) { if (node == null) { return null; } ApiResponses apiResponses = new ApiResponses(); Set<String> keys = getKeys(node); for (String key : keys) { if(underComponents) { if (!Pattern.matches("^[a-zA-Z0-9\\.\\-_]+$", key)) { result.warning(location, "Response key " + key + " doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"); } } if (key.startsWith("x-")) { Map <String,Object> extensions = getExtensions(node); if(extensions != null && extensions.size() > 0) { apiResponses.setExtensions(extensions); } } else { ObjectNode obj = getObject(key, node, false, location, result); if (obj != null) { ApiResponse response = getResponse(obj, String.format("%s.%s", location, key), result); if (response != null) { apiResponses.put(key, response); } } } } return apiResponses; }
Example 3
Source File: DataRestResponseBuilder.java From springdoc-openapi with Apache License 2.0 | 2 votes |
/** * Add response 200. * * @param apiResponses the api responses * @param apiResponse the api response */ private void addResponse200(ApiResponses apiResponses, ApiResponse apiResponse) { apiResponses.put(String.valueOf(HttpStatus.OK.value()), apiResponse.description(HttpStatus.OK.getReasonPhrase())); }
Example 4
Source File: DataRestResponseBuilder.java From springdoc-openapi with Apache License 2.0 | 2 votes |
/** * Add response 204. * * @param apiResponses the api responses */ private void addResponse204(ApiResponses apiResponses) { apiResponses.put(String.valueOf(HttpStatus.NO_CONTENT.value()), new ApiResponse().description(HttpStatus.NO_CONTENT.getReasonPhrase())); }
Example 5
Source File: DataRestResponseBuilder.java From springdoc-openapi with Apache License 2.0 | 2 votes |
/** * Add response 404. * * @param apiResponses the api responses */ private void addResponse404(ApiResponses apiResponses) { apiResponses.put(String.valueOf(HttpStatus.NOT_FOUND.value()), new ApiResponse().description(HttpStatus.NOT_FOUND.getReasonPhrase())); }