Class OpenAPINormalizer


  • public class OpenAPINormalizer
    extends Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  OpenAPINormalizer.Filter  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static org.slf4j.Logger LOGGER  
      protected io.swagger.v3.oas.models.OpenAPI openAPI  
    • Constructor Summary

      Constructors 
      Constructor Description
      OpenAPINormalizer​(io.swagger.v3.oas.models.OpenAPI openAPI, Map<String,​String> inputRules)
      Initializes OpenAPI Normalizer with a set of rules
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected OpenAPINormalizer.Filter createFilter​(io.swagger.v3.oas.models.OpenAPI openApi, String filters)
      Create the filter to process the FILTER normalizer.
      static OpenAPINormalizer createNormalizer​(io.swagger.v3.oas.models.OpenAPI openAPI, Map<String,​String> inputRules)
      Factory constructor for OpenAPINormalizer.
      protected io.swagger.v3.oas.models.media.Schema createSimplifiedEnumSchema​(io.swagger.v3.oas.models.media.Schema originalSchema, Map<Object,​String> enumValues, String schemaType, String composedType)
      Creates a simplified enum schema from collected enum values.
      protected void ensureInheritanceForDiscriminatorMapping​(io.swagger.v3.oas.models.media.Schema parent, io.swagger.v3.oas.models.media.Schema child, String parentName, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      If not already present, add in the child an allOf referencing the parent.
      protected void ensureInheritanceForDiscriminatorMappings​(io.swagger.v3.oas.models.media.Schema parent, String parentName)
      ensure that all schemas referenced in the discriminator mapping has an allOf to the parent schema.
      void fixSelfReferenceSchema​(String name, io.swagger.v3.oas.models.media.Schema schema)
      Auto fix a self referencing schema using any type to replace the self-referencing sub-item.
      protected String getDiscriminatorValue​(String refSchema, String discriminatorPropertyName, boolean propertyAlreadyPresent, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      Best effort to retrieve a good discriminator value.
      boolean getRule​(String ruleName)
      Get the rule.
      protected boolean isSelfReference​(String name, io.swagger.v3.oas.models.media.Schema subSchema)  
      protected void markSchemaAsVisited​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      Add the schema to the collection of visited schemas.
      protected void normalize()
      Normalizes the OpenAPI input, which may not perfectly conform to the specification.
      protected io.swagger.v3.oas.models.media.Schema normalizeAllOf​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)  
      protected io.swagger.v3.oas.models.media.Schema normalizeAllOfWithProperties​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)  
      protected io.swagger.v3.oas.models.media.Schema normalizeAnyOf​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)  
      protected io.swagger.v3.oas.models.media.Schema normalizeArraySchema​(io.swagger.v3.oas.models.media.Schema schema)  
      protected void normalizeBooleanSchema​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)  
      protected io.swagger.v3.oas.models.media.Schema normalizeComplexComposedSchema​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)  
      protected void normalizeComponentsHeaders()
      Normalizes schemas in component's headers.
      protected void normalizeComponentsResponses()
      Normalizes schemas in component's responses.
      protected void normalizeComponentsSchemas()
      Normalizes schemas in components
      protected void normalizeComponentsSecuritySchemes()
      Normalizes securitySchemes in components
      protected void normalizeContent​(io.swagger.v3.oas.models.media.Content content)
      Normalizes schemas in content
      protected void normalizeHeaders​(Map<String,​io.swagger.v3.oas.models.headers.Header> headers)
      Normalizes schemas in headers
      protected void normalizeInfo()
      Pre-populate info if it's not defined.
      protected void normalizeIntegerSchema​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)  
      protected io.swagger.v3.oas.models.media.Schema normalizeMapSchema​(io.swagger.v3.oas.models.media.Schema schema)  
      protected io.swagger.v3.oas.models.media.Schema normalizeOneOf​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)  
      protected void normalizeOperation​(io.swagger.v3.oas.models.Operation operation)
      Normalizes operation
      protected void normalizeParameters​(List<io.swagger.v3.oas.models.parameters.Parameter> parameters)
      Normalizes schemas in parameters
      protected void normalizePaths()
      Normalizes inline models in Paths
      protected void normalizeProperties​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)  
      protected void normalizeReferenceSchema​(io.swagger.v3.oas.models.media.Schema schema)
      Normalize reference schema with allOf to support sibling properties
      protected void normalizeRequestBody​(io.swagger.v3.oas.models.Operation operation)
      Normalizes schemas in RequestBody
      protected void normalizeResponse​(io.swagger.v3.oas.models.responses.ApiResponse apiResponse)
      Normalizes schemas in ApiResponse
      protected void normalizeResponses​(io.swagger.v3.oas.models.Operation operation)
      Normalizes schemas in ApiResponses
      io.swagger.v3.oas.models.media.Schema normalizeSchema​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      Normalizes a schema
      protected io.swagger.v3.oas.models.media.Schema normalizeSimpleSchema​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)  
      protected void processAddUnsignedToIntegerWithInvalidMaxValue​(io.swagger.v3.oas.models.media.Schema schema)
      If the schema is integer and the max value is invalid (out of bound) then add x-unsigned to use unsigned integer/long instead.
      protected void processFixDuplicatedOperationId​(io.swagger.v3.oas.models.Operation operation)  
      protected void processKeepOnlyFirstTagInOperation​(io.swagger.v3.oas.models.Operation operation)
      Keep only first tag in the operation if the operation has more than one tag.
      protected io.swagger.v3.oas.models.media.Schema processNormalize31Spec​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      When set to true, normalize schema so that it works well with the generator.
      protected void processNormalizeOtherThanObjectWithProperties​(io.swagger.v3.oas.models.media.Schema schema)
      When set to true, remove "properties" attribute on schema other than "object" since it should be ignored and may result in odd generated code
      protected io.swagger.v3.oas.models.media.Schema processRefactorAllOfWithPropertiesOnly​(io.swagger.v3.oas.models.media.Schema schema)
      When set to true, refactor schema with allOf and properties in the same level to a schema with allOf only and the allOf contains a new schema containing the properties in the top level.
      protected void processRemoveAnyOfOneOfAndKeepPropertiesOnly​(io.swagger.v3.oas.models.media.Schema schema)
      If the schema contains anyOf/oneOf and properties, remove oneOf/anyOf as these serve as rules to ensure inter-dependency between properties.
      protected void processRemoveXInternalFromOperation​(io.swagger.v3.oas.models.Operation operation)
      Remove/hide the x-internal in operations and model.
      protected io.swagger.v3.oas.models.media.Schema processReplaceOneOfByMapping​(io.swagger.v3.oas.models.media.Schema schema)
      Ensure inheritance is correctly defined for OneOf and Discriminators.
      void processRules​(Map<String,​String> inputRules)
      Process the rules.
      protected io.swagger.v3.oas.models.media.Schema processSetArraytoNullable​(io.swagger.v3.oas.models.media.Schema schema)
      Set nullable to true in array/set if needed.
      protected io.swagger.v3.oas.models.media.Schema processSetMapToNullable​(io.swagger.v3.oas.models.media.Schema schema)
      Set nullable to true in map if needed.
      protected io.swagger.v3.oas.models.media.Schema processSetPrimitiveTypesToNullable​(io.swagger.v3.oas.models.media.Schema schema)
      Set nullable to true in primitive types (e.g. string) if needed.
      protected void processSetTagsForAllOperations​(io.swagger.v3.oas.models.Operation operation)
      Set the tag name for all operations
      protected void processSetTagsToOperationId​(io.swagger.v3.oas.models.Operation operation)
      Set the tag name to operationId (or "default" if operationId is empty)
      protected void processSetTagsToVendorExtension​(io.swagger.v3.oas.models.Operation operation)
      Set the tag name to the value of the provided vendor extension
      protected io.swagger.v3.oas.models.media.Schema processSimplifyAnyOf​(io.swagger.v3.oas.models.media.Schema schema)
      If the schema is anyOf and the sub-schemas is null, set `nullable: true` instead.
      protected io.swagger.v3.oas.models.media.Schema processSimplifyAnyOfEnum​(io.swagger.v3.oas.models.media.Schema schema)
      If the schema is anyOf and all sub-schemas are enums (with one or more values), then simplify it to a single enum schema containing all the values.
      protected io.swagger.v3.oas.models.media.Schema processSimplifyAnyOfStringAndEnumString​(io.swagger.v3.oas.models.media.Schema schema)
      If the schema is anyOf and the sub-schemas are either string or enum of string, then simplify it to just enum of string as many generators do not yet support anyOf.
      protected void processSimplifyBooleanEnum​(io.swagger.v3.oas.models.media.Schema schema)
      If the schema is boolean and its enum is defined, then simply it to just boolean.
      protected io.swagger.v3.oas.models.media.Schema processSimplifyOneOf​(io.swagger.v3.oas.models.media.Schema schema)
      If the schema is oneOf and the sub-schemas is null, set `nullable: true` instead.
      protected io.swagger.v3.oas.models.media.Schema processSimplifyOneOfEnum​(io.swagger.v3.oas.models.media.Schema schema)
      If the schema is oneOf and all sub-schemas are enums (with one or more values), then simplify it to a single enum schema containing all the values.
      protected void processUseAllOfRefAsParent​(io.swagger.v3.oas.models.media.Schema schema)
      Child schemas in `allOf` is considered a parent if it's a `$ref` (instead of inline schema).
      protected void refactorAllOfWithMetadataOnlySchemas​(io.swagger.v3.oas.models.media.Schema schema)  
      protected void removeUnsupportedSchemasFromAllOf​(io.swagger.v3.oas.models.media.Schema schema)  
      protected io.swagger.v3.oas.models.media.Schema setNullable​(io.swagger.v3.oas.models.media.Schema schema)  
      protected io.swagger.v3.oas.models.media.Schema simplifyComposedSchemaWithEnums​(io.swagger.v3.oas.models.media.Schema schema, List<Object> subSchemas, String composedType)
      Simplifies a composed schema (oneOf/anyOf) where all sub-schemas are enums to a single enum schema containing all the values.
      protected boolean skipNormalization​(io.swagger.v3.oas.models.media.Schema schema, Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      Check if normalization is needed.
    • Field Detail

      • openAPI

        protected io.swagger.v3.oas.models.OpenAPI openAPI
      • LOGGER

        protected static final org.slf4j.Logger LOGGER
    • Constructor Detail

      • OpenAPINormalizer

        public OpenAPINormalizer​(io.swagger.v3.oas.models.OpenAPI openAPI,
                                 Map<String,​String> inputRules)
        Initializes OpenAPI Normalizer with a set of rules
        Parameters:
        openAPI - OpenAPI
        inputRules - a map of rules
    • Method Detail

      • createNormalizer

        public static OpenAPINormalizer createNormalizer​(io.swagger.v3.oas.models.OpenAPI openAPI,
                                                         Map<String,​String> inputRules)
        Factory constructor for OpenAPINormalizer. Default can be overriden by setting the NORMALIZER_CLASS rule
      • getRule

        public boolean getRule​(String ruleName)
        Get the rule.
        Parameters:
        ruleName - the name of the rule
        Returns:
        true if the rule is set
      • processRules

        public void processRules​(Map<String,​String> inputRules)
        Process the rules.
        Parameters:
        inputRules - a map of rules
      • createFilter

        protected OpenAPINormalizer.Filter createFilter​(io.swagger.v3.oas.models.OpenAPI openApi,
                                                        String filters)
        Create the filter to process the FILTER normalizer. Override this to create a custom filter normalizer.
        Parameters:
        openApi - Contract used in the filtering (could be used for customization).
        filters - full FILTER value
        Returns:
        a Filter containing the parsed filters.
      • normalize

        protected void normalize()
        Normalizes the OpenAPI input, which may not perfectly conform to the specification.
      • normalizeInfo

        protected void normalizeInfo()
        Pre-populate info if it's not defined.
      • normalizePaths

        protected void normalizePaths()
        Normalizes inline models in Paths
      • normalizeOperation

        protected void normalizeOperation​(io.swagger.v3.oas.models.Operation operation)
        Normalizes operation
        Parameters:
        operation - Operation
      • normalizeContent

        protected void normalizeContent​(io.swagger.v3.oas.models.media.Content content)
        Normalizes schemas in content
        Parameters:
        content - target content
      • normalizeRequestBody

        protected void normalizeRequestBody​(io.swagger.v3.oas.models.Operation operation)
        Normalizes schemas in RequestBody
        Parameters:
        operation - target operation
      • normalizeParameters

        protected void normalizeParameters​(List<io.swagger.v3.oas.models.parameters.Parameter> parameters)
        Normalizes schemas in parameters
        Parameters:
        parameters - List parameters
      • normalizeResponses

        protected void normalizeResponses​(io.swagger.v3.oas.models.Operation operation)
        Normalizes schemas in ApiResponses
        Parameters:
        operation - target operation
      • normalizeResponse

        protected void normalizeResponse​(io.swagger.v3.oas.models.responses.ApiResponse apiResponse)
        Normalizes schemas in ApiResponse
        Parameters:
        apiResponse - API response
      • normalizeHeaders

        protected void normalizeHeaders​(Map<String,​io.swagger.v3.oas.models.headers.Header> headers)
        Normalizes schemas in headers
        Parameters:
        headers - a map of headers
      • normalizeComponentsSecuritySchemes

        protected void normalizeComponentsSecuritySchemes()
        Normalizes securitySchemes in components
      • normalizeComponentsSchemas

        protected void normalizeComponentsSchemas()
        Normalizes schemas in components
      • normalizeComponentsResponses

        protected void normalizeComponentsResponses()
        Normalizes schemas in component's responses.
      • normalizeComponentsHeaders

        protected void normalizeComponentsHeaders()
        Normalizes schemas in component's headers.
      • fixSelfReferenceSchema

        public void fixSelfReferenceSchema​(String name,
                                           io.swagger.v3.oas.models.media.Schema schema)
        Auto fix a self referencing schema using any type to replace the self-referencing sub-item.
        Parameters:
        name - Schema name
        schema - Schema
      • isSelfReference

        protected boolean isSelfReference​(String name,
                                          io.swagger.v3.oas.models.media.Schema subSchema)
      • normalizeSchema

        public io.swagger.v3.oas.models.media.Schema normalizeSchema​(io.swagger.v3.oas.models.media.Schema schema,
                                                                     Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
        Normalizes a schema
        Parameters:
        schema - Schema
        visitedSchemas - a set of visited schemas
        Returns:
        Schema
      • normalizeReferenceSchema

        protected void normalizeReferenceSchema​(io.swagger.v3.oas.models.media.Schema schema)
        Normalize reference schema with allOf to support sibling properties
        Parameters:
        schema - Schema
      • skipNormalization

        protected boolean skipNormalization​(io.swagger.v3.oas.models.media.Schema schema,
                                            Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
        Check if normalization is needed. No normalization needed if the schema is null or is a $ref or already processed.
        Parameters:
        schema - Schema
        visitedSchemas - a set of visited schemas
        Returns:
        false if normalization is needed
      • markSchemaAsVisited

        protected void markSchemaAsVisited​(io.swagger.v3.oas.models.media.Schema schema,
                                           Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
        Add the schema to the collection of visited schemas.
        Parameters:
        schema - schema to add
        visitedSchemas - current visited schemas
      • normalizeArraySchema

        protected io.swagger.v3.oas.models.media.Schema normalizeArraySchema​(io.swagger.v3.oas.models.media.Schema schema)
      • normalizeMapSchema

        protected io.swagger.v3.oas.models.media.Schema normalizeMapSchema​(io.swagger.v3.oas.models.media.Schema schema)
      • normalizeSimpleSchema

        protected io.swagger.v3.oas.models.media.Schema normalizeSimpleSchema​(io.swagger.v3.oas.models.media.Schema schema,
                                                                              Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      • normalizeBooleanSchema

        protected void normalizeBooleanSchema​(io.swagger.v3.oas.models.media.Schema schema,
                                              Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      • normalizeIntegerSchema

        protected void normalizeIntegerSchema​(io.swagger.v3.oas.models.media.Schema schema,
                                              Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      • normalizeProperties

        protected void normalizeProperties​(io.swagger.v3.oas.models.media.Schema schema,
                                           Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      • refactorAllOfWithMetadataOnlySchemas

        protected void refactorAllOfWithMetadataOnlySchemas​(io.swagger.v3.oas.models.media.Schema schema)
      • removeUnsupportedSchemasFromAllOf

        protected void removeUnsupportedSchemasFromAllOf​(io.swagger.v3.oas.models.media.Schema schema)
      • normalizeAllOf

        protected io.swagger.v3.oas.models.media.Schema normalizeAllOf​(io.swagger.v3.oas.models.media.Schema schema,
                                                                       Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      • normalizeAllOfWithProperties

        protected io.swagger.v3.oas.models.media.Schema normalizeAllOfWithProperties​(io.swagger.v3.oas.models.media.Schema schema,
                                                                                     Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      • normalizeOneOf

        protected io.swagger.v3.oas.models.media.Schema normalizeOneOf​(io.swagger.v3.oas.models.media.Schema schema,
                                                                       Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      • normalizeAnyOf

        protected io.swagger.v3.oas.models.media.Schema normalizeAnyOf​(io.swagger.v3.oas.models.media.Schema schema,
                                                                       Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      • normalizeComplexComposedSchema

        protected io.swagger.v3.oas.models.media.Schema normalizeComplexComposedSchema​(io.swagger.v3.oas.models.media.Schema schema,
                                                                                       Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
      • processUseAllOfRefAsParent

        protected void processUseAllOfRefAsParent​(io.swagger.v3.oas.models.media.Schema schema)
        Child schemas in `allOf` is considered a parent if it's a `$ref` (instead of inline schema).
        Parameters:
        schema - Schema
      • processRemoveXInternalFromOperation

        protected void processRemoveXInternalFromOperation​(io.swagger.v3.oas.models.Operation operation)
        Remove/hide the x-internal in operations and model.
        Parameters:
        operation - Operation
      • processKeepOnlyFirstTagInOperation

        protected void processKeepOnlyFirstTagInOperation​(io.swagger.v3.oas.models.Operation operation)
        Keep only first tag in the operation if the operation has more than one tag.
        Parameters:
        operation - Operation
      • processSetTagsForAllOperations

        protected void processSetTagsForAllOperations​(io.swagger.v3.oas.models.Operation operation)
        Set the tag name for all operations
        Parameters:
        operation - Operation
      • processSetTagsToOperationId

        protected void processSetTagsToOperationId​(io.swagger.v3.oas.models.Operation operation)
        Set the tag name to operationId (or "default" if operationId is empty)
        Parameters:
        operation - Operation
      • processSetTagsToVendorExtension

        protected void processSetTagsToVendorExtension​(io.swagger.v3.oas.models.Operation operation)
        Set the tag name to the value of the provided vendor extension
        Parameters:
        operation - Operation
      • processFixDuplicatedOperationId

        protected void processFixDuplicatedOperationId​(io.swagger.v3.oas.models.Operation operation)
      • processRemoveAnyOfOneOfAndKeepPropertiesOnly

        protected void processRemoveAnyOfOneOfAndKeepPropertiesOnly​(io.swagger.v3.oas.models.media.Schema schema)
        If the schema contains anyOf/oneOf and properties, remove oneOf/anyOf as these serve as rules to ensure inter-dependency between properties. It's a workaround as such validation is not supported at the moment.
        Parameters:
        schema - Schema
      • processSimplifyAnyOfStringAndEnumString

        protected io.swagger.v3.oas.models.media.Schema processSimplifyAnyOfStringAndEnumString​(io.swagger.v3.oas.models.media.Schema schema)
        If the schema is anyOf and the sub-schemas are either string or enum of string, then simplify it to just enum of string as many generators do not yet support anyOf.
        Parameters:
        schema - Schema
        Returns:
        Schema
      • processSimplifyAnyOfEnum

        protected io.swagger.v3.oas.models.media.Schema processSimplifyAnyOfEnum​(io.swagger.v3.oas.models.media.Schema schema)
        If the schema is anyOf and all sub-schemas are enums (with one or more values), then simplify it to a single enum schema containing all the values.
        Parameters:
        schema - Schema
        Returns:
        Schema
      • processSimplifyOneOfEnum

        protected io.swagger.v3.oas.models.media.Schema processSimplifyOneOfEnum​(io.swagger.v3.oas.models.media.Schema schema)
        If the schema is oneOf and all sub-schemas are enums (with one or more values), then simplify it to a single enum schema containing all the values.
        Parameters:
        schema - Schema
        Returns:
        Schema
      • simplifyComposedSchemaWithEnums

        protected io.swagger.v3.oas.models.media.Schema simplifyComposedSchemaWithEnums​(io.swagger.v3.oas.models.media.Schema schema,
                                                                                        List<Object> subSchemas,
                                                                                        String composedType)
        Simplifies a composed schema (oneOf/anyOf) where all sub-schemas are enums to a single enum schema containing all the values.
        Parameters:
        schema - Schema to modify
        subSchemas - List of sub-schemas to check
        composedType - Type of composed schema ("oneOf" or "anyOf")
        Returns:
        Simplified schema
      • createSimplifiedEnumSchema

        protected io.swagger.v3.oas.models.media.Schema createSimplifiedEnumSchema​(io.swagger.v3.oas.models.media.Schema originalSchema,
                                                                                   Map<Object,​String> enumValues,
                                                                                   String schemaType,
                                                                                   String composedType)
        Creates a simplified enum schema from collected enum values.
        Parameters:
        originalSchema - Original schema to modify
        enumValues - Collected enum values
        schemaType - Consistent type across sub-schemas
        composedType - Type of composed schema being simplified
        Returns:
        Simplified enum schema
      • processSimplifyOneOf

        protected io.swagger.v3.oas.models.media.Schema processSimplifyOneOf​(io.swagger.v3.oas.models.media.Schema schema)
        If the schema is oneOf and the sub-schemas is null, set `nullable: true` instead. If there's only one sub-schema, simply return the sub-schema directly.
        Parameters:
        schema - Schema
        Returns:
        Schema
      • processReplaceOneOfByMapping

        protected io.swagger.v3.oas.models.media.Schema processReplaceOneOfByMapping​(io.swagger.v3.oas.models.media.Schema schema)
        Ensure inheritance is correctly defined for OneOf and Discriminators. For schemas containing oneOf and discriminator.propertyName:
        • Create the mappings as $refs
        • Remove OneOf
      • getDiscriminatorValue

        protected String getDiscriminatorValue​(String refSchema,
                                               String discriminatorPropertyName,
                                               boolean propertyAlreadyPresent,
                                               Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
        Best effort to retrieve a good discriminator value. By order of precedence:
        • x-discriminator-value
        • single enum value for attribute used by the discriminator.propertyName
        • hame of the schema
        Parameters:
        refSchema - $ref value like #/components/schemas/Dog
        discriminatorPropertyName - name of the property used in the discriminator mapping
        propertyAlreadyPresent - if true, delete the property in the referenced schemas to avoid duplicates
        Returns:
        the name
      • ensureInheritanceForDiscriminatorMappings

        protected void ensureInheritanceForDiscriminatorMappings​(io.swagger.v3.oas.models.media.Schema parent,
                                                                 String parentName)
        ensure that all schemas referenced in the discriminator mapping has an allOf to the parent schema. This allows DefaultCodeGen to detect inheritance.
        Parameters:
        parent - parent schma
        parentName - name of the parent schema
      • ensureInheritanceForDiscriminatorMapping

        protected void ensureInheritanceForDiscriminatorMapping​(io.swagger.v3.oas.models.media.Schema parent,
                                                                io.swagger.v3.oas.models.media.Schema child,
                                                                String parentName,
                                                                Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
        If not already present, add in the child an allOf referencing the parent.
      • processSetArraytoNullable

        protected io.swagger.v3.oas.models.media.Schema processSetArraytoNullable​(io.swagger.v3.oas.models.media.Schema schema)
        Set nullable to true in array/set if needed.
        Parameters:
        schema - Schema
        Returns:
        Schema
      • processSetPrimitiveTypesToNullable

        protected io.swagger.v3.oas.models.media.Schema processSetPrimitiveTypesToNullable​(io.swagger.v3.oas.models.media.Schema schema)
        Set nullable to true in primitive types (e.g. string) if needed.
        Parameters:
        schema - Schema
        Returns:
        Schema
      • setNullable

        protected io.swagger.v3.oas.models.media.Schema setNullable​(io.swagger.v3.oas.models.media.Schema schema)
      • processSetMapToNullable

        protected io.swagger.v3.oas.models.media.Schema processSetMapToNullable​(io.swagger.v3.oas.models.media.Schema schema)
        Set nullable to true in map if needed.
        Parameters:
        schema - Schema
        Returns:
        Schema
      • processSimplifyAnyOf

        protected io.swagger.v3.oas.models.media.Schema processSimplifyAnyOf​(io.swagger.v3.oas.models.media.Schema schema)
        If the schema is anyOf and the sub-schemas is null, set `nullable: true` instead. If there's only one sub-schema, simply return the sub-schema directly.
        Parameters:
        schema - Schema
        Returns:
        Schema
      • processSimplifyBooleanEnum

        protected void processSimplifyBooleanEnum​(io.swagger.v3.oas.models.media.Schema schema)
        If the schema is boolean and its enum is defined, then simply it to just boolean.
        Parameters:
        schema - Schema
      • processAddUnsignedToIntegerWithInvalidMaxValue

        protected void processAddUnsignedToIntegerWithInvalidMaxValue​(io.swagger.v3.oas.models.media.Schema schema)
        If the schema is integer and the max value is invalid (out of bound) then add x-unsigned to use unsigned integer/long instead.
        Parameters:
        schema - Schema
      • processRefactorAllOfWithPropertiesOnly

        protected io.swagger.v3.oas.models.media.Schema processRefactorAllOfWithPropertiesOnly​(io.swagger.v3.oas.models.media.Schema schema)
        When set to true, refactor schema with allOf and properties in the same level to a schema with allOf only and the allOf contains a new schema containing the properties in the top level.
        Parameters:
        schema - Schema
        Returns:
        Schema
      • processNormalize31Spec

        protected io.swagger.v3.oas.models.media.Schema processNormalize31Spec​(io.swagger.v3.oas.models.media.Schema schema,
                                                                               Set<io.swagger.v3.oas.models.media.Schema> visitedSchemas)
        When set to true, normalize schema so that it works well with the generator.
        Parameters:
        schema - Schema
        visitedSchemas - a set of visited schemas
        Returns:
        Schema
      • processNormalizeOtherThanObjectWithProperties

        protected void processNormalizeOtherThanObjectWithProperties​(io.swagger.v3.oas.models.media.Schema schema)
        When set to true, remove "properties" attribute on schema other than "object" since it should be ignored and may result in odd generated code
        Parameters:
        schema - Schema