# Copyright © ICTU
# Licensed under the EUPL

# checkov:skip=CKV_OPENAPI_4: skip security because api is unsecured
# checkov:skip=CKV_OPENAPI_5
openapi: 3.0.3
info:
  title: FDS Catalog Registry
  version: 1.0.0
  description: API for registering DCAT catalog endpoints for harvesting by the FDS catalog.
servers:
  - url: https://{registryURL}
    variables:
      registryURL:
        default: localhost
        description: URL of the API
paths:
  /v1/registrations:
    post:
      operationId: postRegistration
      summary: Submit a DCAT catalog URL for registration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RegistrationRequest"
      responses:
        "201":
          description: Registration submitted for approval
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RegistrationResponse"
        "400":
          description: Invalid URL or not valid DCAT
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetail"
        "409":
          description: URL or domain already registered or pending approval
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetail"
        "429":
          description: Rate limit exceeded
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetail"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetail"
        "503":
          description: Too many concurrent registrations
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetail"
    get:
      operationId: getRegistrations
      summary: DCAT catalog of registered catalog endpoints
      responses:
        "200":
          description: Registered DCAT catalog endpoints in Turtle format
          content:
            text/turtle:
              schema:
                type: string
        "500":
          description: Internal Server Error
  /v1/health:
    get:
      operationId: getHealth
      summary: Health endpoint
      responses:
        "200":
          description: Service is healthy
        "503":
          description: Service is unhealthy
components:
  schemas:
    RegistrationRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
    RegistrationResponse:
      type: object
      properties:
        merge_request_url:
          type: string
    ProblemDetail:
      type: object
      description: RFC 7807 Problem Details
      required:
        - type
        - title
        - status
      properties:
        type:
          type: string
          format: uri
          example: about:blank
        title:
          type: string
          example: Bad Request
        status:
          type: integer
          example: 400
        detail:
          type: string
          example: URL does not contain valid DCAT data
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
