Java Code Examples for io.swagger.v3.oas.models.parameters.Parameter#getExtensions()
The following examples show how to use
io.swagger.v3.oas.models.parameters.Parameter#getExtensions() .
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: DefaultSpecFilter.java From swagger-inflector with Apache License 2.0 | 5 votes |
@Override public Optional<Parameter> filterParameter(Parameter parameter, Operation operation, ApiDescription api, Map<String, List<String>> params, Map<String, String> cookies, Map<String, List<String>> headers) { if(parameter.getExtensions() != null && parameter.getExtensions().containsKey(Constants.X_INFLECTOR_HIDDEN)) { return Optional.empty(); } return Optional.of(parameter); }
Example 2
Source File: GenericParameterBuilder.java From springdoc-openapi with Apache License 2.0 | 4 votes |
/** * Merge parameter. * * @param paramCalcul the param calcul * @param paramDoc the param doc */ private static void mergeParameter(Parameter paramCalcul, Parameter paramDoc) { if (StringUtils.isBlank(paramDoc.getDescription())) paramDoc.setDescription(paramCalcul.getDescription()); if (StringUtils.isBlank(paramDoc.getIn())) paramDoc.setIn(paramCalcul.getIn()); if (paramDoc.getExample() == null) paramDoc.setExample(paramCalcul.getExample()); if (paramDoc.getDeprecated() == null) paramDoc.setDeprecated(paramCalcul.getDeprecated()); if (paramDoc.getRequired() == null) paramDoc.setRequired(paramCalcul.getRequired()); if (paramDoc.getAllowEmptyValue() == null) paramDoc.setAllowEmptyValue(paramCalcul.getAllowEmptyValue()); if (paramDoc.getAllowReserved() == null) paramDoc.setAllowReserved(paramCalcul.getAllowReserved()); if (StringUtils.isBlank(paramDoc.get$ref())) paramDoc.set$ref(paramDoc.get$ref()); if (paramDoc.getSchema() == null) paramDoc.setSchema(paramCalcul.getSchema()); if (paramDoc.getExamples() == null) paramDoc.setExamples(paramCalcul.getExamples()); if (paramDoc.getExtensions() == null) paramDoc.setExtensions(paramCalcul.getExtensions()); if (paramDoc.getStyle() == null) paramDoc.setStyle(paramCalcul.getStyle()); if (paramDoc.getExplode() == null) paramDoc.setExplode(paramCalcul.getExplode()); }
Example 3
Source File: PythonAbstractConnexionServerCodegen.java From openapi-generator with Apache License 2.0 | 4 votes |
@Override public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) { // XXX - Revert the original parameter (and path) names to make sure we have // a consistent REST interface across other server/client languages: // // XXX - Reverts `x-python-connexion-openapi-name` back to the original (query/path) parameter name. // We do not want to have our REST API itself being converted to pythonic params. // This would be incompatible with other server implementations. OpenAPI openAPI = (OpenAPI) objs.get("openAPI"); Map<String, PathItem> paths = openAPI.getPaths(); if (paths != null) { List<String> pathnames = new ArrayList(paths.keySet()); for (String pythonPathname : pathnames) { PathItem path = paths.get(pythonPathname); // Fix path parameters back to original casing Map<String, Object> pathExtensions = path.getExtensions(); if (pathExtensions != null) { // Get and remove the (temporary) vendor extension String openapiPathname = (String) pathExtensions.remove("x-python-connexion-openapi-name"); if (openapiPathname != null && !openapiPathname.equals(pythonPathname)) { LOGGER.info("Path '" + pythonPathname + "' is not consistant with the original OpenAPI definition. It will be replaced back by '" + openapiPathname + "'"); paths.remove(pythonPathname); paths.put(openapiPathname, path); } } Map<HttpMethod, Operation> operationMap = path.readOperationsMap(); if (operationMap != null) { for (HttpMethod method : operationMap.keySet()) { Operation operation = operationMap.get(method); if (operation.getParameters() != null) { for (Parameter parameter : operation.getParameters()) { Map<String, Object> parameterExtensions = parameter.getExtensions(); if (parameterExtensions != null) { // Get and remove the (temporary) vendor extension String swaggerParameterName = (String) parameterExtensions.remove("x-python-connexion-openapi-name"); if (swaggerParameterName != null) { String pythonParameterName = parameter.getName(); if (!swaggerParameterName.equals(pythonParameterName)) { LOGGER.info("Reverting name of parameter '" + pythonParameterName + "' of operation '" + operation.getOperationId() + "' back to '" + swaggerParameterName + "'"); parameter.setName(swaggerParameterName); } else { LOGGER.debug("Name of parameter '" + pythonParameterName + "' of operation '" + operation.getOperationId() + "' was unchanged."); } } else { LOGGER.debug("x-python-connexion-openapi-name was not set on parameter '" + parameter.getName() + "' of operation '" + operation.getOperationId() + "'"); } } } } } } } // Sort path names after variable name fix List<String> recoveredPathnames = new ArrayList(paths.keySet()); Collections.sort(recoveredPathnames); for (String pathname : recoveredPathnames) { PathItem pathItem = paths.remove(pathname); paths.put(pathname, pathItem); } } generateJSONSpecFile(objs); generateYAMLSpecFile(objs); for (Map<String, Object> operations : getOperations(objs)) { @SuppressWarnings("unchecked") List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation"); List<Map<String, Object>> opsByPathList = sortOperationsByPath(ops); operations.put("operationsByPath", opsByPathList); } return super.postProcessSupportingFileData(objs); }