public class ModelUtils extends Object
| Constructor and Description |
|---|
ModelUtils() |
| Modifier and Type | Method and Description |
|---|---|
static io.swagger.v3.oas.models.media.Schema |
getAdditionalProperties(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
Returns the additionalProperties Schema for the specified input schema.
|
static List<String> |
getAllParentsName(io.swagger.v3.oas.models.media.ComposedSchema composedSchema,
Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas,
boolean includeAncestors)
Get the list of parent model names from the schemas (allOf, anyOf, oneOf).
|
static List<io.swagger.v3.oas.models.media.Schema> |
getAllSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
Return the list of all schemas in the 'components/schemas' section of an openAPI specification,
including inlined schemas and children of composed schemas.
|
static List<String> |
getAllUsedSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
Return the list of all schemas in the 'components/schemas' section used in the openAPI specification
|
static io.swagger.v3.oas.models.responses.ApiResponse |
getApiResponse(io.swagger.v3.oas.models.OpenAPI openAPI,
String name) |
static io.swagger.v3.oas.models.callbacks.Callback |
getCallback(io.swagger.v3.oas.models.OpenAPI openAPI,
String name) |
static Map<String,List<String>> |
getChildrenMap(io.swagger.v3.oas.models.OpenAPI openAPI) |
static io.swagger.v3.oas.models.headers.Header |
getHeader(io.swagger.v3.oas.models.OpenAPI openAPI,
String name) |
static List<io.swagger.v3.oas.models.media.Schema> |
getInterfaces(io.swagger.v3.oas.models.media.ComposedSchema composed)
Get the interfaces from the schema (composed)
|
static CodegenModel |
getModelByName(String name,
Map<String,ModelsMap> models)
Searches for the model by name in the map of models and returns it
|
static SemVer |
getOpenApiVersion(io.swagger.v3.oas.models.OpenAPI openAPI,
String location,
List<io.swagger.v3.parser.core.models.AuthorizationValue> auths)
Parse the OAS document at the specified location, get the swagger or openapi version
as specified in the source document, and return the version.
|
static io.swagger.v3.oas.models.parameters.Parameter |
getParameter(io.swagger.v3.oas.models.OpenAPI openAPI,
String name) |
static String |
getParentName(io.swagger.v3.oas.models.media.ComposedSchema composedSchema,
Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas)
Get the parent model name from the composed schema (allOf, anyOf, oneOf).
|
static io.swagger.v3.oas.models.responses.ApiResponse |
getReferencedApiResponse(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.responses.ApiResponse apiResponse)
If a ApiResponse contains a reference to another ApiResponse with '$ref', returns the referenced ApiResponse if it is found or the actual ApiResponse in the other cases.
|
static io.swagger.v3.oas.models.callbacks.Callback |
getReferencedCallback(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.callbacks.Callback callback)
If a Callback contains a reference to another Callback with '$ref', returns the referenced Callback if it is found or the actual Callback in the other cases.
|
static io.swagger.v3.oas.models.headers.Header |
getReferencedHeader(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.headers.Header header) |
static io.swagger.v3.oas.models.parameters.Parameter |
getReferencedParameter(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.parameters.Parameter parameter)
If a Parameter contains a reference to another Parameter with '$ref', returns the referenced Parameter if it is found or the actual Parameter in the other cases.
|
static io.swagger.v3.oas.models.parameters.RequestBody |
getReferencedRequestBody(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.parameters.RequestBody requestBody)
If a RequestBody contains a reference to another RequestBody with '$ref', returns the referenced RequestBody if it is found or the actual RequestBody in the other cases.
|
static io.swagger.v3.oas.models.media.Schema |
getReferencedSchema(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
If a Schema contains a reference to another Schema with '$ref', returns the referenced Schema if it is found or the actual Schema in the other cases.
|
static io.swagger.v3.oas.models.parameters.RequestBody |
getRequestBody(io.swagger.v3.oas.models.OpenAPI openAPI,
String name) |
static io.swagger.v3.oas.models.media.Schema |
getSchema(io.swagger.v3.oas.models.OpenAPI openAPI,
String name) |
static io.swagger.v3.oas.models.media.Schema |
getSchemaFromRequestBody(io.swagger.v3.oas.models.parameters.RequestBody requestBody)
Return the first defined Schema for a RequestBody
|
static io.swagger.v3.oas.models.media.Schema |
getSchemaFromResponse(io.swagger.v3.oas.models.responses.ApiResponse response)
Return the first defined Schema for a ApiResponse
|
static Map<String,io.swagger.v3.oas.models.media.Schema> |
getSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
Return a Map of the schemas defined under /components/schemas in the OAS document.
|
static List<String> |
getSchemasUsedOnlyInFormParam(io.swagger.v3.oas.models.OpenAPI openAPI)
Return the list of schemas in the 'components/schemas' used only in a 'application/x-www-form-urlencoded' or 'multipart/form-data' mime time
|
static String |
getSimpleRef(String ref) |
static List<String> |
getUnusedSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
Return the list of unused schemas in the 'components/schemas' section of an openAPI specification
|
static boolean |
hasAllOf(io.swagger.v3.oas.models.media.Schema schema)
Returns true if the schema contains allOf and may or may not have
properties/oneOf/anyOf defined.
|
static boolean |
hasAnyOf(io.swagger.v3.oas.models.media.Schema schema)
Returns true if the schema contains anyOf and may or may not have
properties/allOf/oneOf defined.
|
static boolean |
hasCommonAttributesDefined(io.swagger.v3.oas.models.media.Schema schema)
Returns true if any of the common attributes of the schema (e.g.
|
static boolean |
hasOneOf(io.swagger.v3.oas.models.media.Schema schema)
Returns true if the schema contains oneOf and may or may not have
properties/allOf/anyOf defined.
|
static boolean |
hasSelfReference(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
Has self reference?
|
static boolean |
hasSelfReference(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema,
Set<String> visitedSchemaNames)
Has self reference?
|
static boolean |
hasValidation(io.swagger.v3.oas.models.media.Schema sc) |
static boolean |
isAllOf(io.swagger.v3.oas.models.media.Schema schema)
Returns true if the schema contains allOf but
no properties/oneOf/anyOf defined.
|
static boolean |
isAllOfWithProperties(io.swagger.v3.oas.models.media.Schema schema)
Returns true if the schema contains allOf and properties,
and no oneOf/anyOf defined.
|
static boolean |
isAnyOf(io.swagger.v3.oas.models.media.Schema schema)
Returns true if the schema contains anyOf but
no properties/allOf/anyOf defined.
|
static boolean |
isAnyType(io.swagger.v3.oas.models.media.Schema schema)
For when a type is not defined on a schema
Note: properties, additionalProperties, enums, validations, items, and composed schemas (oneOf/anyOf/allOf)
can be defined or omitted on these any type schemas
|
static boolean |
isArraySchema(io.swagger.v3.oas.models.media.Schema schema)
Return true if the specified schema is an array of items.
|
static boolean |
isBinarySchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isBooleanSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isByteArraySchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isComplexComposedSchema(io.swagger.v3.oas.models.media.Schema schema)
Return true if the specified schema is composed with more than one of the following:
'oneOf', 'anyOf' or 'allOf'.
|
static boolean |
isComposedSchema(io.swagger.v3.oas.models.media.Schema schema)
Return true if the specified schema is composed, i.e.
|
static boolean |
isDateSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isDateTimeSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isDecimalSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isDisallowAdditionalPropertiesIfNotPresent() |
static boolean |
isDoubleSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isEmailSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isExtensionParent(io.swagger.v3.oas.models.media.Schema schema)
If it's a boolean, returns the value of the extension `x-parent`.
|
static boolean |
isFileSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isFloatSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isFreeFormObject(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
Check to see if the schema is a free form object.
|
static boolean |
isGenerateAliasAsModel() |
static boolean |
isGenerateAliasAsModel(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isIntegerSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isLongSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isMapSchema(io.swagger.v3.oas.models.media.Schema schema)
Return true if the specified 'schema' is an object that can be extended with additional properties.
|
static boolean |
isModel(io.swagger.v3.oas.models.media.Schema schema)
Check to see if the schema is a model
|
static boolean |
isModelWithPropertiesOnly(io.swagger.v3.oas.models.media.Schema schema)
Check to see if the schema is a model with properties only (non-composed model)
|
static boolean |
isNullable(io.swagger.v3.oas.models.media.Schema schema)
Return true if the 'nullable' attribute is set to true in the schema, i.e.
|
static boolean |
isNullableComposedSchema(io.swagger.v3.oas.models.media.ComposedSchema schema)
Return true if the specified composed schema is 'oneOf', contains one or two elements,
and at least one of the elements is the 'null' type.
|
static boolean |
isNullType(io.swagger.v3.oas.models.media.Schema schema)
isNullType returns true if the input schema is the 'null' type.
|
static boolean |
isNumberSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isObjectSchema(io.swagger.v3.oas.models.media.Schema schema)
Return true if the specified schema is an object with a fixed number of properties.
|
static boolean |
isOneOf(io.swagger.v3.oas.models.media.Schema schema)
Returns true if the schema contains oneOf but
no properties/allOf/anyOf defined.
|
static boolean |
isPasswordSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isSet(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isShortSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isStringSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isTypeObjectSchema(io.swagger.v3.oas.models.media.Schema schema)
Return true if the specified schema is type object
We can't use isObjectSchema because it requires properties to exist which is not required
We can't use isMap because it is true for AnyType use cases
|
static boolean |
isUnsignedIntegerSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isUnsignedLongSchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isURISchema(io.swagger.v3.oas.models.media.Schema schema) |
static boolean |
isUUIDSchema(io.swagger.v3.oas.models.media.Schema schema) |
static com.fasterxml.jackson.databind.JsonNode |
readWithInfo(String location,
List<io.swagger.v3.parser.core.models.AuthorizationValue> auths)
Parse and return a JsonNode representation of the input OAS document.
|
static void |
setDisallowAdditionalPropertiesIfNotPresent(boolean value) |
static void |
setGenerateAliasAsModel(boolean value) |
static void |
syncValidationProperties(io.swagger.v3.oas.models.media.Schema schema,
IJsonSchemaValidationProperties target) |
static io.swagger.v3.oas.models.media.Schema |
unaliasSchema(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
Get the actual schema from aliases.
|
static io.swagger.v3.oas.models.media.Schema |
unaliasSchema(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema,
Map<String,String> schemaMappings)
Get the actual schema from aliases.
|
public static boolean isDisallowAdditionalPropertiesIfNotPresent()
public static void setDisallowAdditionalPropertiesIfNotPresent(boolean value)
public static boolean isGenerateAliasAsModel()
public static void setGenerateAliasAsModel(boolean value)
public static boolean isGenerateAliasAsModel(io.swagger.v3.oas.models.media.Schema schema)
public static CodegenModel getModelByName(String name, Map<String,ModelsMap> models)
name - Name of the modelmodels - Map of modelspublic static List<String> getAllUsedSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - specificationpublic static List<String> getUnusedSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - specificationpublic static List<String> getSchemasUsedOnlyInFormParam(io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - specificationpublic static boolean isTypeObjectSchema(io.swagger.v3.oas.models.media.Schema schema)
schema - the OAS schemapublic static boolean isObjectSchema(io.swagger.v3.oas.models.media.Schema schema)
A ObjectSchema differs from a MapSchema in the following way: - An ObjectSchema is not extensible, i.e. it has a fixed number of properties. - A MapSchema is an object that can be extended with an arbitrary set of properties. The payload may include dynamic properties.
For example, an OpenAPI schema is considered an ObjectSchema in the following scenarios:
type: object additionalProperties: false properties: name: type: string address: type: string
schema - the OAS schemapublic static boolean isComposedSchema(io.swagger.v3.oas.models.media.Schema schema)
schema - the OAS schemapublic static boolean isComplexComposedSchema(io.swagger.v3.oas.models.media.Schema schema)
schema - the OAS schemapublic static boolean isMapSchema(io.swagger.v3.oas.models.media.Schema schema)
A MapSchema differs from an ObjectSchema in the following way: - An ObjectSchema is not extensible, i.e. it has a fixed number of properties. - A MapSchema is an object that can be extended with an arbitrary set of properties. The payload may include dynamic properties.
Note that isMapSchema returns true for a composed schema (allOf, anyOf, oneOf) that also defines additionalproperties.
For example, an OpenAPI schema is considered a MapSchema in the following scenarios:
type: object additionalProperties: true type: object additionalProperties: type: object properties: code: type: integer allOf: - $ref: '#/components/schemas/Class1' - $ref: '#/components/schemas/Class2' additionalProperties: true
schema - the OAS schemapublic static boolean isArraySchema(io.swagger.v3.oas.models.media.Schema schema)
schema - the OAS schemapublic static boolean isSet(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isStringSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isIntegerSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isShortSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isUnsignedIntegerSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isLongSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isUnsignedLongSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isBooleanSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isNumberSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isFloatSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isDoubleSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isDateSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isDateTimeSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isPasswordSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isByteArraySchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isBinarySchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isFileSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isUUIDSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isURISchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isEmailSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isDecimalSchema(io.swagger.v3.oas.models.media.Schema schema)
public static boolean isModel(io.swagger.v3.oas.models.media.Schema schema)
schema - potentially containing a '$ref'public static boolean isModelWithPropertiesOnly(io.swagger.v3.oas.models.media.Schema schema)
schema - potentially containing a '$ref'public static boolean hasValidation(io.swagger.v3.oas.models.media.Schema sc)
public static boolean isFreeFormObject(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
A free form object is an object (i.e. 'type: object' in a OAS document) that: 1) Does not define properties, and 2) Is not a composed schema (no anyOf, oneOf, allOf), and 3) additionalproperties is not defined, or additionalproperties: true, or additionalproperties: {}.
Examples:
components: schemas: arbitraryObject: type: object description: This is a free-form object. The value must be a map of strings to values. The value cannot be 'null'. It cannot be array, string, integer, number. arbitraryNullableObject: type: object description: This is a free-form object. The value must be a map of strings to values. The value can be 'null', It cannot be array, string, integer, number. nullable: true arbitraryTypeValue: description: This is NOT a free-form object. The value can be any type except the 'null' value.
openAPI - the object that encapsulates the OAS document.schema - potentially containing a '$ref'public static io.swagger.v3.oas.models.media.Schema getReferencedSchema(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
openAPI - specification being checkedschema - potentially containing a '$ref'public static io.swagger.v3.oas.models.media.Schema getSchema(io.swagger.v3.oas.models.OpenAPI openAPI,
String name)
public static Map<String,io.swagger.v3.oas.models.media.Schema> getSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - the OpenAPI document.public static List<io.swagger.v3.oas.models.media.Schema> getAllSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - OpenAPI documentpublic static io.swagger.v3.oas.models.parameters.RequestBody getReferencedRequestBody(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.parameters.RequestBody requestBody)
openAPI - specification being checkedrequestBody - potentially containing a '$ref'public static io.swagger.v3.oas.models.parameters.RequestBody getRequestBody(io.swagger.v3.oas.models.OpenAPI openAPI,
String name)
public static io.swagger.v3.oas.models.responses.ApiResponse getReferencedApiResponse(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.responses.ApiResponse apiResponse)
openAPI - specification being checkedapiResponse - potentially containing a '$ref'public static io.swagger.v3.oas.models.responses.ApiResponse getApiResponse(io.swagger.v3.oas.models.OpenAPI openAPI,
String name)
public static io.swagger.v3.oas.models.parameters.Parameter getReferencedParameter(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.parameters.Parameter parameter)
openAPI - specification being checkedparameter - potentially containing a '$ref'public static io.swagger.v3.oas.models.parameters.Parameter getParameter(io.swagger.v3.oas.models.OpenAPI openAPI,
String name)
public static io.swagger.v3.oas.models.callbacks.Callback getReferencedCallback(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.callbacks.Callback callback)
openAPI - specification being checkedcallback - potentially containing a '$ref'public static io.swagger.v3.oas.models.callbacks.Callback getCallback(io.swagger.v3.oas.models.OpenAPI openAPI,
String name)
public static io.swagger.v3.oas.models.media.Schema getSchemaFromRequestBody(io.swagger.v3.oas.models.parameters.RequestBody requestBody)
requestBody - request body of the operationpublic static io.swagger.v3.oas.models.media.Schema getSchemaFromResponse(io.swagger.v3.oas.models.responses.ApiResponse response)
response - api response of the operationpublic static boolean hasSelfReference(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
openAPI - OpenAPI spec.schema - Schemapublic static boolean hasSelfReference(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema,
Set<String> visitedSchemaNames)
openAPI - OpenAPI spec.schema - SchemavisitedSchemaNames - A set of visited schema namespublic static io.swagger.v3.oas.models.media.Schema unaliasSchema(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
openAPI - specification being checkedschema - schema (alias or direct reference)public static io.swagger.v3.oas.models.media.Schema unaliasSchema(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema,
Map<String,String> schemaMappings)
openAPI - OpenAPI document containing the schemas.schema - schema (alias or direct reference)schemaMappings - mappings of external types to be omitted by unaliasingpublic static io.swagger.v3.oas.models.media.Schema getAdditionalProperties(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.media.Schema schema)
The additionalProperties keyword is used to control the handling of additional, undeclared properties, that is, properties whose names are not listed in the properties keyword. The additionalProperties keyword may be either a boolean or an object. If additionalProperties is a boolean and set to false, no additional properties are allowed. By default when the additionalProperties keyword is not specified in the input schema, any additional properties are allowed. This is equivalent to setting additionalProperties to the boolean value True or setting additionalProperties: {}
openAPI - the object that encapsulates the OAS document.schema - the input schema that may or may not have the additionalProperties keyword.public static io.swagger.v3.oas.models.headers.Header getReferencedHeader(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.headers.Header header)
public static io.swagger.v3.oas.models.headers.Header getHeader(io.swagger.v3.oas.models.OpenAPI openAPI,
String name)
public static Map<String,List<String>> getChildrenMap(io.swagger.v3.oas.models.OpenAPI openAPI)
public static List<io.swagger.v3.oas.models.media.Schema> getInterfaces(io.swagger.v3.oas.models.media.ComposedSchema composed)
composed - schema (alias or direct reference)public static String getParentName(io.swagger.v3.oas.models.media.ComposedSchema composedSchema, Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas)
For example, given the following OAS spec, the parent of 'Dog' is Animal because 'Animal' specifies a discriminator.
animal: type: object discriminator: propertyName: type properties: type: string
dog: allOf: - $ref: '#/components/schemas/animal' - type: object properties: breed: string
composedSchema - schema (alias or direct reference)allSchemas - all schemaspublic static List<String> getAllParentsName(io.swagger.v3.oas.models.media.ComposedSchema composedSchema, Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas, boolean includeAncestors)
composedSchema - schema (alias or direct reference)allSchemas - all schemasincludeAncestors - if true, include the indirect ancestors in the return value. If false, return the direct parents.public static boolean isExtensionParent(io.swagger.v3.oas.models.media.Schema schema)
schema - Schemapublic static boolean isNullable(io.swagger.v3.oas.models.media.Schema schema)
In addition, if the OAS document is 3.1 or above, isNullable returns true if the input schema is a 'oneOf' composed document with at most two children, and one of the children is the 'null' type.
The caller is responsible for resolving schema references before invoking isNullable. If the input schema is a $ref and the referenced schema has 'nullable: true', this method returns false (because the nullable attribute is defined in the referenced schema).
The 'nullable' attribute was introduced in OAS 3.0. The 'nullable' attribute is deprecated in OAS 3.1. In a OAS 3.1 document, the preferred way to specify nullable properties is to use the 'null' type.
schema - the OAS schema.public static boolean isNullableComposedSchema(io.swagger.v3.oas.models.media.ComposedSchema schema)
The 'null' type is supported in OAS 3.1 and above. In the example below, the 'OptionalOrder' can have the null value because the 'null' type is one of the elements under 'oneOf'.
OptionalOrder: oneOf: - type: 'null' - $ref: '#/components/schemas/Order'
schema - the OAS composed schema.public static boolean isNullType(io.swagger.v3.oas.models.media.Schema schema)
The 'null' type is supported in OAS 3.1 and above. It is not supported in OAS 2.0 and OAS 3.0.x.
For example, the "null" type could be used to specify that a value must either be null or a specified type:
OptionalOrder: oneOf: - type: 'null' - $ref: '#/components/schemas/Order'
schema - the OpenAPI schemapublic static boolean isAnyType(io.swagger.v3.oas.models.media.Schema schema)
schema - the schema that we are checkingpublic static void syncValidationProperties(io.swagger.v3.oas.models.media.Schema schema,
IJsonSchemaValidationProperties target)
public static com.fasterxml.jackson.databind.JsonNode readWithInfo(String location, List<io.swagger.v3.parser.core.models.AuthorizationValue> auths) throws Exception
location - the URL of the OAS document.auths - the list of authorization values to access the remote URL.Exception - if an error occurs while retrieving the OpenAPI document.public static SemVer getOpenApiVersion(io.swagger.v3.oas.models.OpenAPI openAPI, String location, List<io.swagger.v3.parser.core.models.AuthorizationValue> auths)
For OAS 2.0 documents, return the value of the 'swagger' attribute. For OAS 3.x documents, return the value of the 'openapi' attribute.
openAPI - the object that encapsulates the OAS document.location - the URL of the OAS document.auths - the list of authorization values to access the remote URL.public static boolean isAllOf(io.swagger.v3.oas.models.media.Schema schema)
schema - the schemapublic static boolean hasAllOf(io.swagger.v3.oas.models.media.Schema schema)
schema - the schemapublic static boolean isAllOfWithProperties(io.swagger.v3.oas.models.media.Schema schema)
schema - the schemapublic static boolean isOneOf(io.swagger.v3.oas.models.media.Schema schema)
schema - the schemapublic static boolean hasOneOf(io.swagger.v3.oas.models.media.Schema schema)
schema - the schemapublic static boolean isAnyOf(io.swagger.v3.oas.models.media.Schema schema)
schema - the schemapublic static boolean hasAnyOf(io.swagger.v3.oas.models.media.Schema schema)
schema - the schemapublic static boolean hasCommonAttributesDefined(io.swagger.v3.oas.models.media.Schema schema)
schema - the schemaCopyright © 2023. All rights reserved.