Java Code Examples for io.swagger.v3.oas.models.media.Schema#getExtensions()
The following examples show how to use
io.swagger.v3.oas.models.media.Schema#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: SchemaUtils.java From tcases with MIT License | 6 votes |
/** * Returns the given schema after removing all but the given schemas. */ private static Schema<?> withExtensions( Schema<?> schema, String... extensions) { Map<String,Object> extAll = schema.getExtensions(); if( extAll!= null) { schema.setExtensions( null); for( String ext : extensions) { if( extAll.containsKey( ext)) { schema.addExtension( ext, extAll.get( ext)); } } } return schema; }
Example 2
Source File: VendorSpecFilter.java From swagger-inflector with Apache License 2.0 | 6 votes |
@Override public Map<String, Schema> filterComponentsSchema(OpenAPISpecFilter filter, Map<String, Schema> definitions, Map<String, List<String>> params, Map<String, String> cookies, Map<String, List<String>> headers) { final Map<String, Schema> filteredDefinitions = super.filterComponentsSchema(filter, definitions, params, cookies, headers); if( filteredDefinitions != null ) { for (Schema model : filteredDefinitions.values()) { if(model != null && model.getExtensions() != null) { filterVendorExtensions(model.getExtensions()); } } } return filteredDefinitions; }
Example 3
Source File: ExtensionsUtil.java From swagger-inflector with Apache License 2.0 | 6 votes |
public void removeExtensions(OpenAPI openAPI) { if (openAPI.getComponents() == null || openAPI.getComponents().getSchemas() == null) { schemas = new HashMap<>(); } else { schemas = openAPI.getComponents().getSchemas(); for (String name : schemas.keySet()) { Schema schema = schemas.get(name); if (schema.getExtensions() != null) { if (schema.getExtensions().containsKey(Constants.X_SWAGGER_ROUTER_MODEL)) { Map<String,Schema> extensions = schema.getExtensions(); Object value = extensions.get(Constants.X_SWAGGER_ROUTER_MODEL); extensions.remove(Constants.X_SWAGGER_ROUTER_MODEL,value); } } } } if (openAPI.getPaths() != null) { for (String pathname : openAPI.getPaths().keySet()) { PathItem pathItem = openAPI.getPaths().get(pathname); resolvePath(pathItem,false); } } }
Example 4
Source File: ExtensionsUtil.java From swagger-inflector with Apache License 2.0 | 6 votes |
public void addExtensions(OpenAPI openAPI) { if (openAPI.getComponents() == null || openAPI.getComponents().getSchemas() == null) { schemas = new HashMap<>(); } else { schemas = openAPI.getComponents().getSchemas(); for (String name : schemas.keySet()) { Schema schema = schemas.get(name); if (schema.getExtensions() != null) { if (!schema.getExtensions().containsKey(Constants.X_SWAGGER_ROUTER_MODEL)) { schema.addExtension(Constants.X_SWAGGER_ROUTER_MODEL, name); } } else { schema.addExtension(Constants.X_SWAGGER_ROUTER_MODEL, name); } } } if (openAPI.getPaths() != null) { for (String pathname : openAPI.getPaths().keySet()) { PathItem pathItem = openAPI.getPaths().get(pathname); resolvePath(pathItem, true); } } }
Example 5
Source File: VaadinConnectTsGenerator.java From flow with Apache License 2.0 | 5 votes |
private String getDescriptionFromParameterExtension(String paramName, Schema requestSchema) { if (requestSchema.getExtensions() == null) { return ""; } Map<String, String> paramDescription = (Map<String, String>) requestSchema .getExtensions() .get(OpenApiObjectGenerator.EXTENSION_VAADIN_CONNECT_PARAMETERS_DESCRIPTION); return paramDescription.getOrDefault(paramName, ""); }
Example 6
Source File: DefaultSpecFilter.java From swagger-inflector with Apache License 2.0 | 5 votes |
@Override public Optional<Schema> filterSchemaProperty(Schema model, Schema property, String propertyName, Map<String, List<String>> params, Map<String, String> cookies, Map<String, List<String>> headers) { if(property.getExtensions() != null && property.getExtensions().containsKey(Constants.X_INFLECTOR_HIDDEN)) { return Optional.empty(); } return Optional.of(property); }
Example 7
Source File: InlineModelResolver.java From swagger-parser with Apache License 2.0 | 5 votes |
/** * Copy vendor extensions from Property to another Property * * @param source source property * @param target target property */ public void copyVendorExtensions(Schema source, Schema target) { if (source.getExtensions() != null) { Map<String, Object> vendorExtensions = source.getExtensions(); for (String extName : vendorExtensions.keySet()) { target.addExtension(extName, vendorExtensions.get(extName)); } } }
Example 8
Source File: OASMergeUtil.java From crnk-framework with Apache License 2.0 | 4 votes |
public static Schema mergeSchema(Schema thisSchema, Schema thatSchema) { if (thatSchema == null) { return thisSchema; } // Overwriting `implementation` is explicitly disallowed // Overwriting `not` is explicitly disallowed // Overwriting `oneOf` is explicitly disallowed // Overwriting `anyOf` is explicitly disallowed // Overwriting `allOf` is explicitly disallowed // Overwriting `name` is explicitly disallowed if (thatSchema.getTitle() != null) { thisSchema.setTitle(thatSchema.getTitle()); } // Overwriting `multipleOf` is explicitly disallowed if (thatSchema.getMaximum() != null) { thisSchema.setMaximum(thatSchema.getMaximum()); } if (thatSchema.getExclusiveMaximum() != null) { thisSchema.setExclusiveMaximum(thatSchema.getExclusiveMaximum()); } if (thatSchema.getMinimum() != null) { thisSchema.setMinimum(thatSchema.getMinimum()); } if (thatSchema.getExclusiveMinimum() != null) { thisSchema.setExclusiveMinimum(thatSchema.getExclusiveMinimum()); } if (thatSchema.getMaxLength() != null) { thisSchema.setMaxLength(thatSchema.getMaxLength()); } if (thatSchema.getMinLength() != null) { thisSchema.setMinLength(thatSchema.getMinLength()); } if (thatSchema.getPattern() != null) { thisSchema.setPattern(thatSchema.getPattern()); } if (thatSchema.getMaxProperties() != null) { thisSchema.setMaxProperties(thatSchema.getMaxProperties()); } if (thatSchema.getMinProperties() != null) { thisSchema.setMinProperties(thatSchema.getMinProperties()); } // RequiredProperties if (thatSchema.getRequired() != null) { thisSchema.setRequired(thatSchema.getRequired()); } // Overwriting `name` is explicitly disallowed if (thatSchema.getDescription() != null) { thisSchema.setDescription(thatSchema.getDescription()); } if (thatSchema.getFormat() != null) { thisSchema.setFormat(thatSchema.getFormat()); } // Overwriting `ref` is explicitly disallowed if (thatSchema.getNullable() != null) { thisSchema.setNullable(thatSchema.getNullable()); } // Overwriting `AccessMode` is explicitly disallowed if (thatSchema.getExample() != null) { thisSchema.setExample(thatSchema.getExample()); } if (thatSchema.getExternalDocs() != null) { thisSchema.setExternalDocs(thatSchema.getExternalDocs()); } if (thatSchema.getDeprecated() != null) { thisSchema.setDeprecated(thatSchema.getDeprecated()); } if (thatSchema.getType() != null) { thisSchema.setType(thatSchema.getType()); } if (thatSchema.getEnum() != null) { thisSchema.setEnum(thatSchema.getEnum()); } if (thatSchema.getDefault() != null) { thisSchema.setDefault(thatSchema.getDefault()); } // Overwriting `discriminator` is explicitly disallowed // Overwriting `hidden` is explicitly disallowed // Overwriting `subTypes` is explicitly disallowed if (thatSchema.getExtensions() != null) { thisSchema.setExtensions(thatSchema.getExtensions()); } return thisSchema; }