swagger: '2.0'

info:
  version: "0.1.0"
  title: Schema Service
  description: |
    Service managing schemas

host: haleconnect.com
schemes:
  - https
basePath: /schemas

produces:
  - application/json

security:
  - bearer: []

securityDefinitions:
  bearer:
    type: apiKey
    name: Authorization
    in: header

paths:
  /schemas:
    get:
      tags:
        - Schemas
      summary: List all schemas
      parameters:
        - $ref: '#/parameters/public'
      responses:
        200:
          $ref: '#/responses/SchemaList'
    # post:
    #   tags:
    #     - Draft
    #   summary: Create a new schema
    #   description: |
    #     Create a new schema from uploaded files or a remote schema location
    #   consumes:
    #     - application/json
    #     - multipart/form-data
    #   parameters:
    #     - in: body
    #       name: body
    #       description: Information on the schema to be created
    #       # required: true
    #       schema:
    #         $ref: '#/definitions/NewSchema'
    #     - in: formData
    #       name: file
    #       description: A schema file
    #       type: file
    #     - in: formData
    #       name: name
    #       description: The schema name
    #       # required: true
    #       type: string
    #   responses:
    #     200:
    #       description: Schema created
    #       schema:
    #         $ref: '#/definitions/SchemaIdent'
    #     default:
    #       $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
    get:
      tags:
        - Draft
      summary: List schemas of an organisation or user
      responses:
        200:
          $ref: '#/responses/SchemaList'
        default:
          $ref: '#/responses/Error'

    delete:
      summary: Delete all resources related to an organisation
      tags:
        - Purge
      responses:
        200:
          $ref: '#/responses/Info'
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    get:
      summary: Get detailed information on a schema
      tags:
        - Schemas
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/SchemaDetail'
        default:
          $ref: '#/responses/Error'
    delete:
      summary: Delete the schema
      tags:
        - Schemas
      responses:
        200:
          $ref: '#/responses/Info'
        default:
          $ref: '#/responses/Error'


  /schemas/{ownerType}/{ownerId}/{schema}/types/{typeName}/validate:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/typeName'
    get:
      summary: Validates if a type's localName
      description: Determines if a type with the given name can be added to the schema, based on whether a type with that name is already present for the schema's namespace
      tags:
        - Schemas
      responses:
        200:
          description: OK
          schema:
            type: object
            required:
              - validTypeName
            properties:
              validTypeName:
                type: boolean
        default:
          $ref: '#/responses/Error'


  /schemas/{ownerType}/{ownerId}/{schema}/location:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    get:
      summary: Get information about a schema XSD location, if available
      description: Get information about a schema XSD location, if available. Mainly to be used by the workflow manager
      tags:
        - Definitions
      responses:
        200:
          $ref: '#/responses/LocationResponse'
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}/gmlnamespace:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    get:
      summary: Get the GML namespace used by the schema, if any is used
      description: Get the GML namespace used by the schema, if any is used
      tags:
        - Definitions
      responses:
        200:
          $ref: '#/responses/GMLNamespaceResponse'
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}/xmlSchemas:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    get:
      summary: Get information about the XML Schemas used by this schema
      description: Get information about the XML Schemas used by this schema
      tags:
        - Schemas
      responses:
        200:
          $ref: '#/responses/XmlSchemasResponse'
        default:
          $ref: '#/responses/Error'


  /v2/schemas/{ownerType}/{ownerId}/{schema}/download/{format}:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/format'
    get:
      summary: Download a schema in a specific format
      tags:
        - Schemas
      responses:
        200:
          description: OK
        default:
          $ref: '#/responses/Error'

   #TODO make compliant and replace for the /schemas/{ownerType}/{ownerId}/{schema} above
  /schemas/{ownerType}/{ownerId}/{schema}/definition:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    get:
      summary: Gets the schema definition
      tags:
        - Definitions
      responses:
        200:
          $ref: '#/responses/NewSchema'
        default:
          $ref: '#/responses/Error'
    post:
      summary: Adds a schema definition
      tags:
        - Definitions
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          required: true
          schema:
            $ref: '#/definitions/NewSchema'
      responses:
        200:
          $ref: '#/responses/NewSchemaResponse'
        default:
          $ref: '#/responses/Error'
    put:
      summary: Edits a schema definition
      tags:
        - Definitions
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          required: true
          schema:
            $ref: '#/definitions/NewSchema'
      responses:
        200:
          $ref: '#/responses/Info'
        default:
          $ref: '#/responses/Error'
    delete:
      summary: Deletes the schema definition
      tags:
        - Definitions
      responses:
        200:
          $ref: '#/responses/Info'
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}/definition/types:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    get:
      summary: Get information on all types defined in the schema definition
      tags:
        - Definitions
      responses:
        200:
          $ref: '#/responses/NewTypeList'
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}/definition/types:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    post:
      summary: Adds a type to a schema definition
      tags:
        - Definitions
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: Information on the type to be added
          required: true
          schema:
            $ref: '#/definitions/NewType'


  /schemas/{ownerType}/{ownerId}/{schema}/definition/types/{typeId}:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/typeId'
    get:
      summary: Get information on a type
      tags:
        - Definitions
      responses:
        200:
          $ref: '#/definitions/TypeDetail'
        default:
          $ref: '#/responses/Error'

    delete:
      summary: Delete a type from a schema definition
      tags:
        - Definitions
      responses:
        200:
          $ref: '#/responses/Info'
        default:
          $ref: '#/responses/Error'


  /schemas/{ownerType}/{ownerId}/{schema}/definition/types/{typeId}/property/{propertyName}:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/typeId'
      - $ref: '#/parameters/propertyName'
    put:
      summary: Updates a primitive property inside a type
      tags:
        - Definitions
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: The property new value
          required: true
          schema:
            type: string



  /schemas/{ownerType}/{ownerId}/{schema}/types:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    get:
      summary: Get information on all types defined in the schema
      tags:
        - Schemas
      responses:
        200:
          $ref: '#/responses/TypeList'
        default:
          $ref: '#/responses/Error'
    post:
      summary: Get information on a subset of the types defined in the schema definition
      description: Get information on a subset of the types defined in the schema definition, if no specific types are specified, or one of them is not found, all of them are returned, like in the GET endpoint
      tags:
        - Schemas
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          required: true
          schema:
            $ref: '#/definitions/TypeIdentifiersList'
      responses:
        200:
          $ref: '#/responses/NewTypeList'
        default:
          $ref: '#/responses/Error'


  /schemas/{ownerType}/{ownerId}/{schema}/types/{type}:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/schemaType'
    get:
      summary: Get detailed information on a type
      tags:
        - Schemas
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/TypeDetail'
        default:
          $ref: '#/responses/Error'

    put:
      summary: Edits information about a type associated to an schema
      tags:
        - Schemas
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: Information on the type to be added
          required: true
          schema:
            $ref: '#/definitions/NewType'
      responses:
        200:
          description: On successful update.
          schema:
            $ref: '#/definitions/Feedback'
        default:
          $ref: '#/responses/Error'

    delete:
      summary: Deletes a type associated with a schema
      tags:
        - Schemas
      responses:
        200:
          $ref: '#/responses/Info'
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}/types/{localName}/{namespace}:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/localName'
      - $ref: '#/parameters/namespace'
    get:
      summary: Get detailed information on a type
      parameters:
        - in: query
          name: inheritedProps
          description: Whether or not to load the type's inherited properties
          required: false
          type: boolean
      tags:
        - Schemas
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/TypeDefinition'
        default:
          $ref: '#/responses/Error'


  /schemas/{ownerType}/{ownerId}/{schema}/relations:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    get:
      summary: Get the relations of a schema
      tags:
        - Schemas
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/RelationsDetail'
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}/temp/extension:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    get:
      summary: Get temporary information about an incomplete schema extension process
      tags:
        - Temporary Info
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/TempSchemaExtInfo'
        default:
          $ref: '#/responses/Error'

    put:
      summary: Saves information about a uncompleted schema extension process
      tags:
        - Temporary Info
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: Temporary information to be saved about the schema extension process
          required: true
          schema:
            type: object
            required:
              - schema
            properties:
              stepNumber:
                type: integer
              info:
                $ref: '#/definitions/TempSchemaExtInfo'
      responses:
        200:
          description: On successful update.
          schema:
            $ref: '#/definitions/Feedback'
        default:
          $ref: '#/responses/Error'

    post:
      summary: Finishes the extension process generation the final Schema structure
      tags:
        - Temporary Info
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: Optional information about the process being finalized
          required: false
          schema:
            $ref: '#/definitions/ObjectTypeId'
      responses:
        200:
          description: The extension process was finished successfully
          schema:
            $ref: '#/definitions/Feedback'
        default:
          $ref: '#/responses/Error'

    delete:
      summary: Deletes information about a uncompleted schema extension process
      tags:
        - Temporary Info
      responses:
        200:
          $ref: '#/responses/Info'
        default:
          $ref: '#/responses/Error'

  /presets:
    get:
      tags:
        - Presets
      summary: List all schema presets
      responses:
        200:
          $ref: '#/responses/PresetList'

  /codelists:
    get:
      tags:
        - Code List
      summary: List all INSPIRE and service-specific code lists
      responses:
        200:
          $ref: '#/responses/CodeLists'


  /v2/schemas/{ownerType}/{ownerId}/{schema}/types:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    # get:
    #   summary: Get information on all types defined in the schema
    #   tags:
    #     - Schemas
    #   responses:
    #     200:
    #       $ref: '#/responses/NewTypeList'
    #     default:
    #       $ref: '#/responses/Error'
    post:
      summary: Perform a query on the types defined in the schema
      description: Forwards a type query to the underlying MongoDB. Also supports sorting, paging and projections.
      tags:
        - Schemas
        - v2
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          required: true
          schema:
            $ref: '#/definitions/GenericQuery'
      responses:
        200:
          $ref: '#/responses/NewTypeList'
        default:
          $ref: '#/responses/Error'


  /schemas/{ownerType}/{ownerId}/{schema}/profile:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    post:
      summary: Create a profile based on a schema
      tags:
        - Profiles
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: Information on the profile to be updated
          required: true
          schema:
            type: object
            description: Holds data about the profile created
            required:
              - name
            properties:
              name:
                type: string
              author:
                type: string
              description:
                type: string
              version:
                type: string
      responses:
        '200':
          description: The profile was created
        default:
          $ref: '#/responses/Error'


  /schemas/{ownerType}/{ownerId}/{schema}/profile/{profileId}/export:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/profileId'
    get:
      summary: Get the Test Suite XML representation of a schema
      tags:
        - Profiles
      responses:
        200:
          description: Returns the XML file representation of a schema
        default:
          $ref: '#/responses/Error'

  /migration/profile/{profileId}/export:
    parameters:
      - $ref: '#/parameters/profileId'
    get:
      summary: Gets the full information of a profile
      tags:
        - Migration
      responses:
        200:
          description: Gets the full information of a profile
        default:
          $ref: '#/responses/Error'

  /migration/profile/{profileId}/migrate/{ownerType}/{ownerId}/{schema}:
    parameters:
      - $ref: '#/parameters/profileId'
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    post:
      summary: Copies a profile and migrates the copy to a new base schema
      tags:
        - Migration
      consumes:
        - application/json
      responses:
        200:
          description: Copies a profile and migrates the copy to a new base schema
        default:
          $ref: '#/responses/Error'

  /migration/schemas/{ownerType}/{ownerId}/{schema}/profile/restore:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
    post:
      summary: Associate a profile to a schema
      tags:
        - Migration
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: The full JSON representation of the profile
          required: true
          schema:
            $ref: '#/definitions/ProfileConstraint'
      responses:
        200:
          description: Restores a profile using its full representation, with its conditions, constraints and tags, and associates it to an existing schema
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}/profile/{profileId}/copy:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/profileId'
    post:
      summary: Copies a profile
      tags:
        - Profiles
      consumes:
        - application/json
      responses:
        200:
          description: OK
        default:
          $ref: '#/responses/Error'


  /schemas/{ownerType}/{ownerId}/{schema}/profile/{profileId}/type/{typeId}/constraint:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/profileId'
      - $ref: '#/parameters/typeId'

    post:
      summary: Creates a profile constraint
      tags:
        - Profiles
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: Information on the profile to be created
          required: true
          schema:
            $ref: '#/definitions/ProfileConstraint'
      responses:
        200:
          description: On successful creation.
          schema:
            allOf:
              - $ref: '#/definitions/Feedback'
              - type: object
                required:
                  - constraintId
                properties:
                  constraintId:
                    type: string
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}/profile/{profileId}/type/{typeId}/constraint/{constraintId}:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/profileId'
      - $ref: '#/parameters/typeId'
      - $ref: '#/parameters/constraintId'

    put:
      summary: Updates a profile constraint
      tags:
        - Profiles
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: Information on the profile to be updated
          required: true
          schema:
            $ref: '#/definitions/ProfileConstraint'
      responses:
        200:
          description: On successful update.
          schema:
            allOf:
              - $ref: '#/definitions/Feedback'
              - type: object
                required:
                  - constraintId
                properties:
                  constraintId:
                    type: string
        default:
          $ref: '#/responses/Error'

  /schemas/{ownerType}/{ownerId}/{schema}/profile/{profileId}/type/{typeId}/tags:
    parameters:
      - $ref: '#/parameters/ownerType'
      - $ref: '#/parameters/ownerId'
      - $ref: '#/parameters/schemaId'
      - $ref: '#/parameters/profileId'
      - $ref: '#/parameters/typeId'

    get:
      summary: Gets the profile tags associated with a type
      tags:
        - Tags
      responses:
        200:
          $ref: '#/responses/TagList'
        default:
          $ref: '#/responses/Error'

    put:
      summary: Saves a list of tags into a profile
      tags:
        - Tags
      consumes:
        - application/json
      parameters:
        - in: body
          name: body
          description: List of tags
          required: true
          schema:
            type: array
            items:
              $ref: '#/definitions/ProfileTag'
      responses:
        200:
          description: On successful saving.
          $ref: '#/responses/Info'
        default:
          $ref: '#/responses/Error'


parameters:

  ownerType:
    name: ownerType
    in: path
    description: The type of owner the schema belongs to
    required: true
    type: string
    enum:
      - user
      - org

  ownerId:
    name: ownerId
    in: path
    description: The ID of the owner
    required: true
    type: string

  schemaId:
    name: schema
    in: path
    description: Schema ID
    required: true
    type: string

  profileId:
    name: profileId
    in: path
    description: The UUID identifier of a profile
    required: true
    type: string

  constraintId:
    name: constraintId
    in: path
    description: The UUID identifier of a profile constraint
    required: true
    type: string

  schemaType:
    name: type
    in: path
    description: Type identifier
    required: true
    type: string

  typeProperty:
    name: property
    in: path
    description: Property identifier
    required: true
    type: string

  localName:
    name: localName
    in: path
    description: The local name of a type within its schema
    required: true
    type: string

  namespace:
    name: namespace
    in: path
    description: A Schema namespace
    required: true
    type: string

  typeId:
    name: typeId
    in: path
    description: Type identifier
    required: true
    type: string

  typeName:
    name: typeName
    in: path
    description: Proposed type name
    required: true
    type: string

  propertyName:
    name: property
    in: path
    description: The primitive property name
    required: true
    type: string

  public:
    name: public
    in: query
    description: Whether or not to list public schemas
    required: false
    type: boolean

  format:
    name: format
    in: path
    description: The format in which the schema is going to be downloaded
    required: true
    type: string
    enum:
      - hsd
      - hsd.json
      - xsd


definitions:

  SchemaIdent:
    type: object
    description: Holds all information needed to identify a schema
    required:
      - schema
    properties:
      schema:
        type: string
      userId:
        type: string
      orgId:
        type: string

  SchemaInfo:
    type: object
    required:
      - id
    properties:
      id:
        description: Schema identifier
        schema:
          $ref: '#/definitions/SchemaIdent'
      name:
        description: The schema name
        type: string
      created:
        description: The timestamp when the schema was created in the system
        type: integer
      lastModified:
        description: The timestamp when the schema files were last modified
        type: integer
      fileCount:
        description: The number of files representing the schema
        type: integer
      properties:
        description: Generic properties associated to the schema
        type: object

  SchemaDetail:
    allOf:
      - $ref: '#/definitions/SchemaInfo'
      - type: object
        properties:
          #namespaces:
          #  type: object
          #  description: The schema namespaces identified by their prefixes
          mainTypes:
            type: array
            items:
              $ref: '#/definitions/TypeDetail'

  TypeInfo:
    type: object
    required:
      - localName
      - id
    properties:
      localName:
        type: string
        description: The type local name
      namespace:
        type: string
        description: The type namespace
      anonymous:
        type: boolean
        description: |
          States if the type is an anonymous type. An anonymous type does not have a location
          and thus cannot be referenced, it is always included with all details.
      location:
        type: string
        description: The location of the type resource in the API, if it is not an anonymous type
      id:
        type: string
        description: Unique string identifier within the schema
      displayName:
        type: string
        description: The type display name
      description:
        type: string
        description: A type description
      type:
        type: string
        enum:
          - type
          - featureType
        description: States which kind of type this object represents
      superType:
        type: object
        schema:
          # only type reference allowed currently
          $ref: '#/definitions/TypeDetail'
        description: Reference to the type's super type, omitted if the super type is anonymous
      subTypes:
        type: array
        items:
          $ref: '#/definitions/TypeDetail'
      totalSubTypes:
        type: integer
        description: Total number of sub-types
      abstract:
        type: boolean
        description: States if the type is an abstract type
      incomingReferences:
        type: integer
        description: Number of incoming references on the type (currently always 0)
      outgoingReferences:
        type: integer
        description: Number of outgoing references from the type
      inheritanceDepth:
        type: integer
        description: Number of super type levels this type extends from

  TypeDetail:
    allOf:
      - $ref: '#/definitions/TypeInfo'
      - type: object
        properties:
          associations:
            type: array
            items:
              $ref: '#/definitions/PropertyInfo'

  RelationsDetail:
    type: object
    properties:
      imports:
        type: array
        items:
          $ref: '#/definitions/ImportInfo'

  ImportInfo:
    type: object
    required:
      - location
      - namespace
    properties:
      location:
        type: string
        description: The type's location
      namespace:
        type: string
        description: The schema's namespace that contains the type
      name:
        type: string
        description: The schema's name that contains the type
      version:
        type: string
        description: The schema version
      relations:
        type: array
        description: detail information about how this schema is related to the one specified in the URL
        items:
          type: object

  TypeDefinition:
    type: object
    properties:
      name:
        type: string
        description: The type's local name
      namespace:
        type: string
        description: The schema's namespace that contains the type
      name:
        type: string
        description: The schema's name that contains the type
      typeId:
        type: string
        description: The type's identifier
      displayName:
        type: string
        description: The type's display name
      mappingRelevant:
        type: boolean
        description: Whether or not the type is relevant for mapping purposes
      declares:
        type: array
        description: The type's properties
        items:
          type: object


  PropertyInfo:
    type: object
    required:
      - localName
    properties:
      localName:
        type: string
        description: The property local name
      namespace:
        type: string
        description: The property namespace
      displayName:
        type: string
        description: The property display name
      description:
        type: string
        description: A type description
      classification:
        type: string
        enum:
          - numericProperty
          - stringProperty
          - complexProperty
          - geometricProperty
        description: Property classification if the association is a property
      type:
        type: string
        enum:
          - group
          - choice
          - unknown
          - property
        description: The type of association
      inherited:
        type: boolean
        description: States if the property is a property inherited from a super type
      propertyType:
        type: object
        schema:
          # may be reference or anonymous type
          $ref: '#/definitions/TypeDetail'
        description: The property type if this object represents a property
      associations:
        type: array
        items:
          # should be PropertyInfo, but recursive definition not possible
          type: object
        description: The child associations if this object represents a group or choice
      minOccurs:
        type: integer
        description: Minimum occurrence of the property
      maxOccurs:
        # can also be a string!
        type: integer
        description: Maximum occurrence of the property, may be a string that says the maximum occurrence is unbounded
      outgoingReferences:
        type: integer
        description: Number of outgoing references for the property type

  NewSchema:
    type: object
    required:
      - types
    properties:
      id:
        description: Id of this schema
        type: object
        schema:
          $ref: '#/definitions/SchemaIdent'
      namespace:
        type: string
        description: The type namespace

  Location:
    type: object
    required:
      - namespaceUri
    properties:
      namespaceUri:
        description: Namespace of the schema
        type: string
      locationUri:
        type: string
        description: External accesible URL location for the schema

  NewType:
    type: object
    required:
      - name
    properties:
      schema:
        description: Information about the schema from which this type is being referenced
        type: object
        schema:
          $ref: '#/definitions/SchemaIdent'
      name:
        description: The type name
        type: string
      namespace:
        description: The type namespace
        type: string
      description:
        description: The type description
        type: string
      location:
        description: The type location
        type: string
      superType:
        description: Parent of this type
        type: object
      constraints:
        description: The contraints that apply to this type
        type: object
      declares:
        description: The properties declared inside this type
        type: array
        items:
           $ref: '#/definitions/Declares'

  GenericQuery:
    type: object
    properties:
      query:
        description: |
          Generic query passed on to the underlying Mongo DB.
          If the query property is not provided the whole object is treated as query and there is no support for projection, sorting, etc.
        type: object
      fields:
        description: Projection of fields to return in the result
        type: object
      sort:
        description: The Mongo DB sort configuration
        type: object
      limit:
        description: To how many results the query should be limited (for paging)
        type: integer
      skip:
        description: How many results should be skipped (for paging)
        type: integer


  Declares:
    type: object
    properties:
      name:
        description: The property name
        type: string
      description:
        description: The property description
        type: string
      namespace:
        description: The property namespace
        type: string
      propertyType:
        description: The property type
        type: object
      constraints:
        description: Information about the constraints for this property
        type: object
      declares:
        description: The properties contained inside this property. (For the case when this property is of group type)
        type: array
        items:
           $ref: '#/definitions/Declares'


#      groups:
 #       description: The groups that this type contains
  #      type: array
   #     items:
    #       $ref: '#/definitions/Group'



  NewTypeID:
    type: object
    properties:
      typeID:
        description: The ID assigned to the newly created type
        type: string

  NewSchemaID:
    type: object
    properties:
      schemaID:
        description: The ID assigned to the newly created schema definition
        type: string

  ProfileId:
    type: object
    properties:
      id:
        type: string

  Property:
    type: object
    required:
      - name
      - namespace
    properties:
      name:
        description: The property name
        type: string
      namespace:
        description: The property namespace
        type: string
      propertyType:
        description: The property type
        type: string
      constraints:
        description: Information about the constraints for this property
        type: array
        items:
           $ref: '#/definitions/Constraint'
      properties:
        description: The properties contained inside this property. (For the case when this property is of group type)
        type: array
        items:
           $ref: '#/definitions/Property'

  NewPropertyID:
    type: object
    properties:
      propertyID:
        description: The ID assigned to the newly created property
        type: string


  Group:
    type: object
    properties:
      constraints:
        description: The contraints that restrict this group
        type: array
        items:
           $ref: '#/definitions/Constraint'
      properties:
        description: The properties contained inside this group
        type: array
        items:
           $ref: '#/definitions/Property'



  SchemaPreset:
    type: object
    required:
      - id
      - location
    properties:
      id:
        description: Schema preset identifier
        type: string
      location:
        description: The schema location
        type: string
      name:
        description: The schema name
        type: string
      tag:
        description: The schema preset tag
        type: string
      version:
        description: The schema version
        type: string
      description:
        description: The schema description
        type: string
      categoryId:
        description: Preset category identifier
        type: string

  ProfileTag:
    type: object
    required:
      - name
      - value
      - profileId
      - typeId
    properties:
      name:
        description: The name of the tag
        type: string
      value:
        description: The value of the tag
        type: string
      profileId:
        description: The identifier of the profile associated with the tag
        type: string
      typeId:
        description: The identifier of the type associated with the tag
        type: string
      propertyName:
        description: The name of the type property associated with the tag
        type: string
      propertyNamespace:
        description: The namespace of the type property associated with the tag
        type: string

  CodeList:
    type: object
    required:
      - id
      - name
      - description
    properties:
      id:
        description: The code list identifier
        type: string
      name:
        description: The code list name
        type: string
      description:
        description: The code list description
        type: string
      definition:
        description: The code list definition
        type: string
      schemaName:
        description: The name of the schema the code list is associated to
        type: string
      schemaId:
        description: The schema ID and registry URL
        type: string
      location:
        description: The location of the code list
        type: string
      themeName:
        description: The name of the theme the code list is associated to
        type: string
      parentId:
        description: The parent code list identifier
        type: string

  Feedback:
    type: object
    required:
      - code
      - message
      - error
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      error:
        type: boolean

  TypeIdentifier:
    description: Object with information used to identify and return a type contained in a schema
    type: object
    required:
      - localName
      - namespace
    properties:
      localName:
        type: string
      namespace:
        type: string

  LocationXmlSchema:
    description: Object with information about the location of an xml schema
    type: object
    required:
      - location
    properties:
      location:
        type: string

  XmlSchemasObject:
    description: Object with the xml schemas used/referenced by an internal schema
    type: object
    required:
      - xmlSchemas
    properties:
      xmlSchemas:
        type: array
        items:
          $ref: '#/definitions/LocationXmlSchema'

  GMLNamespaceObject:
    description: Object with the xml schemas used/referenced by an internal schema
    type: object
    properties:
      namespace:
        type: string
      usesGML:
        type: boolean

  ObjectTypeId:
    description: Object with additional information about the extension process
    type: object
    properties:
      typeId:
        type: string

  ProfileConstraint:
    description: Object describing a ProfileConstraint
    type: object
    properties:
      constraintType:
        type: string
      value:
        type: object

  TempSchemaExtInfo:
    type: object



responses:

  SchemaList:
    description: Array with information on schemas
    schema:
      type: array
      items:
        $ref: '#/definitions/SchemaInfo'

  PresetList:
    description: Array with information on schema presets
    schema:
      type: array
      items:
        $ref: '#/definitions/SchemaPreset'

  CodeLists:
    description: Array with information on code lists
    schema:
      type: array
      items:
        $ref: '#/definitions/CodeList'

  TypeList:
    description: Array with information on types
    schema:
      type: array
      items:
        $ref: '#/definitions/TypeDetail'

  NewTypeList:
    description: Array with information on types belonging to an schema definition
    schema:
      type: array
      items:
        $ref: '#/definitions/NewType'

  TagList:
    description: Array with profile tags
    schema:
      type: array
      items:
        $ref: '#/definitions/ProfileTag'

  ProfileId:
    description: Internal error processing request
    schema:
      $ref: '#/definitions/Feedback'

  NewSchemaResponse:
    description: Response to creation of a new schema definition
    schema:
      $ref: '#/definitions/NewSchemaID'

  LocationResponse:
    description: Location of a schema
    schema:
      $ref: '#/definitions/Location'

  NewTypeResponse:
    description: Response to creation of a new type
    schema:
      $ref: '#/definitions/NewTypeID'

  NewPropertyResponse:
    description: Response to creation of a new property inside a type
    schema:
      $ref: '#/definitions/NewPropertyID'

  Info:
    description: OK
    schema:
      $ref: '#/definitions/Feedback'


  XmlSchemasResponse:
    description: Response with the xml schemas used/referenced by an internal schema
    schema:
      $ref: '#/definitions/XmlSchemasObject'

  GMLNamespaceResponse:
    description: Response with the GML namespace used/referenced by a schema
    schema:
      $ref: '#/definitions/GMLNamespaceObject'

  Error:
    description: Internal error processing request
    schema:
      $ref: '#/definitions/Feedback'
