---
openapi: 3.1.0
components:
  schemas:
    InvalidProperty:
      type: object
      properties:
        property:
          type: string
        reason:
          type: string
    PagedResultResourceMetadata:
      type: object
      properties:
        elements:
          type: array
          items:
            $ref: "#/components/schemas/ResourceMetadata"
        totalElements:
          type: integer
          format: int64
        pageSize:
          type: integer
          format: int32
    PayloadType:
      type: string
      enum:
      - json
      - json_ld
      - rdf_json
      - rdf_xml
      - turtle
      - n_triples
      - n_quads
      - n3
    ResourceMetadata:
      type: object
      required:
      - name
      - version
      properties:
        id:
          type: integer
          format: int64
        metadataType:
          type: string
        name:
          type: string
        description:
          type: string
        version:
          type: string
          pattern: ^\d+(\.\d+)*$
    ResourceType:
      type: string
      enum:
      - template
      - schema
    ValidationReport:
      type: object
      properties:
        valid:
          type: boolean
        message:
          type: string
        validatedWith:
          type: string
        validationType:
          $ref: "#/components/schemas/ValidationType"
        invalidProperties:
          type: array
          items:
            $ref: "#/components/schemas/InvalidProperty"
    ValidationType:
      type: string
      enum:
      - PLAIN_JSON
      - RDF
  securitySchemes:
    SecurityScheme:
      type: openIdConnect
      description: Authentication
      openIdConnectUrl: http://dpp-registry-kr-gateway:8480/.well-known/openid-configuration
paths:
  /resource/v1/{payloadType}:
    post:
      description: Add a validation resource to the service repository.
      parameters:
      - name: payloadType
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/PayloadType"
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                meta:
                  $ref: "#/components/schemas/ResourceMetadata"
            encoding:
              meta:
                contentType: application/json
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: integer
                format: int64
  /resource/v1/{resourceType}:
    get:
      description: Search for validation resources given input search parameters.
      parameters:
      - description: "The resource type to search. One of template,schema."
        in: path
        name: resourceType
        required: true
        schema:
          $ref: "#/components/schemas/ResourceType"
      - name: description
        in: query
        schema:
          type: string
      - name: limit
        in: query
        schema:
          type: integer
          format: int32
      - name: name
        in: query
        schema:
          type: string
      - name: offset
        in: query
        schema:
          type: integer
          format: int32
      - name: version
        in: query
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PagedResultResourceMetadata"
  /resource/v1/{resourceType}/{id}:
    get:
      description: Retrieve a validation resource by its unique numeric identifier
      parameters:
      - description: "The resource type to retrieve. One of template,schema."
        in: path
        name: resourceType
        required: true
        schema:
          $ref: "#/components/schemas/ResourceType"
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      responses:
        "200":
          description: OK
          content:
            text/plain:
              schema:
                type: string
    delete:
      description: Delete a valiation resource by its unique numeric identifier.
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      - description: "The resource type to delete. One of template,schema."
        in: path
        name: resourceType
        required: true
        schema:
          $ref: "#/components/schemas/ResourceType"
      responses:
        "204":
          description: No Content
  /resource/v1/{resourceType}/{resourceName}/{resourceVersion}:
    get:
      description: Retrieve a validation resource by its name and version.
      parameters:
      - name: resourceName
        in: path
        required: true
        schema:
          type: string
      - description: "The resource type to retrieve. One of template,schema."
        in: path
        name: resourceType
        required: true
        schema:
          $ref: "#/components/schemas/ResourceType"
      - name: resourceVersion
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            text/plain:
              schema:
                type: string
  /validate/v1:
    post:
      summary: Validates a DPP autodetecting the appropriate validation resource to
        apply to it.
      description: Validates a DPP automatically finding the best matching validation
        resource in the service repository to validate it.
      requestBody:
        content:
          application/json:
            schema:
              type: string
              format: binary
          text/json:
            schema:
              type: string
              format: binary
          application/ld+json:
            schema:
              type: string
              format: binary
          application/rdf+json:
            schema:
              type: string
              format: binary
          application/rdf+xml:
            schema:
              type: string
              format: binary
          application/xml:
            schema:
              type: string
              format: binary
          text/xml:
            schema:
              type: string
              format: binary
          application/x+turtle:
            schema:
              type: string
              format: binary
          text/turtle:
            schema:
              type: string
              format: binary
          application/n-triples:
            schema:
              type: string
              format: binary
          text/plain:
            schema:
              type: string
              format: binary
          application/n-quads:
            schema:
              type: string
              format: binary
          text/n3:
            schema:
              type: string
              format: binary
          text/rdf+n3:
            schema:
              type: string
              format: binary
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationReport"
  /validate/v1/{resourceName}/{resourceVersion}:
    post:
      summary: "Validates a DPP retrieving the appropriate validation resource to\
        \ apply to it, by name and version."
      description: Validate a DPP using the name and the version to find the validation
        resource in the service repository to validate it.
      parameters:
      - description: The version of the validation resource to be retrieved to validate
          the input
        in: path
        name: resourceVersion
        required: true
        schema:
          type: string
      - name: resourceName
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              type: string
              format: binary
          text/json:
            schema:
              type: string
              format: binary
          application/ld+json:
            schema:
              type: string
              format: binary
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationReport"
info:
  title: dpp-validator API
  version: 1.1-SNAPSHOT
