Class TypeConverter

java.lang.Object
dk.mada.jaxrs.openapi.TypeConverter

public final class TypeConverter extends Object
Converts a specification schema to an internal model type.
  • Constructor Details

    • TypeConverter

      public TypeConverter(TypeNames typeNames, ParserTypes parserTypes, ParserTypeRefs parserRefs, Naming naming, ParserOpts parserOpts, Parser.LeakedGeneratorOpts leakedGenOpts)
      Constructs a new type converter. This operated by looking up types, creating if missing, in the types instance.
      Parameters:
      typeNames - the type names
      parserTypes - the parser types
      parserRefs - the parser references
      naming - the naming instance
      parserOpts - the parser options
      leakedGenOpts - the leaked generator options
  • Method Details

    • toReference

      public ParserTypeRef toReference(io.swagger.v3.oas.models.media.Schema<?> schema)
      Converts a OpenApi schema to an internal model type.
      Parameters:
      schema - the OpenApi schema to convert
      Returns:
      the found/created internal model type
    • toReference

      public ParserTypeRef toReference(io.swagger.v3.oas.models.media.Schema<?> schema, boolean required)
      Creates the schema reference, but overrides the required state. This is used from parameters, where the required property comes from the parameter.
      Parameters:
      schema - the OpenApi schema to convert
      required - the required value to override in the reference
      Returns:
      the found/created internal model type
    • reference

      public ParserTypeRef reference(io.swagger.v3.oas.models.media.Schema<?> schema, @Nullable String propertyName, @Nullable String parentDtoName, boolean isFormRef)
      Converts a OpenApi schema to parser type reference. This serves as a lazy reference to something that will eventually be resolved to a type in the model.
      Parameters:
      schema - the OpenApi schema to convert
      propertyName - the name of the property the type is associated with, or null
      parentDtoName - the name of the DTO this schema is part of, or null
      isFormRef - true if the reference is a form parameter/field.
      Returns:
      the found/created parser type reference
    • createMultipartDto

      public ParserTypeRef createMultipartDto(String groupOpId, io.swagger.v3.oas.models.media.Schema schema)
      Creates a synthetic DTO for passing multipart form parameters. The name is controlled by the name of the method needing the DTO.
      Parameters:
      groupOpId - the group-operationid of the parent resource method
      schema - the schema of the DTO
      Returns:
      a reference to the created DTO
    • createDto

      public Dto createDto(String dtoName, io.swagger.v3.oas.models.media.Schema<?> schema)
      Creates a DTO from an Object schema.
      Parameters:
      dtoName - the DTO name
      schema - the schema of the DTO
      Returns:
      the create DTO