openapi: 3.0.0
info:
  description: >
    This document specifies an **API Resource Management RESTful API** for **WSO2
    Identity Server**.
  version: "v1"
  title: WSO2 Identity Server - API Resource Management Rest API
  termsOfService: 'http://swagger.io/terms/'
  contact:
    name: WSO2
    url: 'http://wso2.com/products/identity-server/'
    email: architecture@wso2.org
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'

security:
  - OAuth2: []
  - BasicAuth: []

servers:
  - url: 'https://{server-url}/t/{tenant-domain}/api/server/v1'
    variables:
      tenant-domain:
        default: "carbon.super"
      server-url:
        default: "localhost:9443"

paths:
  /api-resources:
    post:
      tags:
        - API Resources
      operationId: addAPIResource
      summary: Add a new API resource
      description: >
        Add a new API resource
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/create <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_create
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIResourceResponse'
        400:
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        404:
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        409:
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/xml:
              schema:
                $ref: '#/components/schemas/Error'
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/APIResourceCreationModel'
        description: This represents the API resource to be created.
        required: true
    get:
      tags:
        - API Resources
      summary: List all API resources in the server
      description: >
        List all API resources in the server
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/view <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_view
      operationId: getAPIResources
      parameters:
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/filter'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/attributes'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIResourceListResponse'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /api-resources/{apiResourceId}:
    get:
      tags:
        - API Resources
      summary: Get API resource specified by the id
      description: >
        Get API resource specified by the id
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/view <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_view
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIResourceResponse'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

    patch:
      tags:
        - API Resources
      summary: Patch API resource specified by the id
      description: >
        Patch API resource specified by the id. Patch operation only supports "name", "description" updating and "addedScopes" fields at the moment.
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/update <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_update
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
      responses:
        204:
          description: Not Content
        400:
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        404:
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        409:
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/xml:
              schema:
                $ref: '#/components/schemas/Error'
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        501:
          description: Not Implemented
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/APIResourcePatchModel'
        description: This represents the API resource to be patched.
        required: true
    delete:
      tags:
        - API Resources
      summary: Delete API resource specified by the id
      description: >
        Delete API resource specified by the id
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/delete <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_delete
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
      responses:
        204:
          description: No Content
        401:
          description: Unauthorized
        403:
          description: Forbidden
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /api-resources/{apiResourceId}/scopes:
    get:
      tags:
        - API Resource Scopes
      summary: Get API resource scopes
      description: >
        Get API resource scopes specified by the id
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/view <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_view
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ScopeGetModel'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        404:
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

    put:
      tags:
        - API Resource Scopes
      summary: Add scopes to API resource
      description: >
        Put scopes API resource specified by the id
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/update <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_update
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
      responses:
        204:
          description: No Content
        400:
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        404:
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        409:
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/xml:
              schema:
                $ref: '#/components/schemas/Error'
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/ScopeCreationModel'
        description: This represents the API resource to be patched.
        required: true

  /api-resources/{apiResourceId}/scopes/{scopeName}:
    patch:
      tags:
        - API Resource Scopes
      summary: Patch scope specified by the name
      description: >
        Patch scope specified by the name. Patch operation only supports "displayName" and "description" fields at the moment.
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/update <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_update
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
        - $ref: '#/components/parameters/scopeName'
      responses:
        204:
          description: Not Content
        400:
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        404:
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScopePatchModel'
        description: This represents the scopes to be patched.
        required: true

    delete:
      tags:
        - API Resource Scopes
      summary: Delete API scope specified by the name
      description: >
        Delete API scope specified by the name
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/delete <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_delete
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
        - $ref: '#/components/parameters/scopeName'
      responses:
        401:
          description: Unauthorized
        403:
          description: Forbidden
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /api-resources/{apiResourceId}/scopes/id/{scopeId}:
    patch:
      tags:
        - API Resource Scopes
      summary: Patch scope specified by the id
      description: >
        Patch scope specified by the id. Patch operation only supports "displayName" and "description" fields at the moment.
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/update <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_update
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
        - $ref: '#/components/parameters/scopeId'
      responses:
        204:
          description: Not Content
        400:
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        404:
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScopePatchModel'
        description: This represents the scopes to be patched.
        required: true

    delete:
      tags:
        - API Resource Scopes
      summary: Delete API scope specified by the id
      description: >
        Delete API scope specified by the id
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/delete <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_delete
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
        - $ref: '#/components/parameters/scopeId'
      responses:
        401:
          description: Unauthorized
        403:
          description: Forbidden
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /scopes:
    get:
      tags:
        - API Resource Scopes
      summary: Get all scopes in the tenant
      description: >
        Get all scopes in the tenant
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/view <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_view
      parameters:
        - $ref: '#/components/parameters/filter'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ScopeGetModel'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        404:
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /api-resources/{apiResourceId}/authorization-details-types:
    get:
      tags:
        - API Resource Authorization Details Types
      description: |
        This API is used to get all registered authorization details types.
        
        <b>Permission required:</b>  
          * /permission/admin/manage/identity/apiresourcemgt/view  
        
        <b>Scope required:</b>  
          * internal_api_resource_view
      summary: Lists all registered authorization details types
      operationId: getAuthorizationDetailsTypes
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
      responses:
        200:
          description: Successfully retrieved a list of authorization details types
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/AuthorizationDetailsTypesGetModel"
        401:
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        404:
          description: Requested resource is not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        500:
          description: Encountered a server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    put:
      tags:
        - API Resource Authorization Details Types
      description: |
        This API is used to add a new authorization details type to API resource.
        
        <b>Permission required:</b>  
          * /permission/admin/manage/identity/apiresourcemgt/update  
        
        <b>Scope required:</b>  
          * internal_api_resource_update
      summary: Adds new authorization details types to the API resource
      operationId: addAuthorizationDetailsTypes
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
      requestBody:
        content:
          "application/json":
            schema:
              type: array
              items:
                $ref: "#/components/schemas/AuthorizationDetailsTypesCreationModel"
      responses:
        200:
          description: Successfully added a list of authorization details types
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/AuthorizationDetailsTypesGetModel"
        401:
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        404:
          description: Requested resource is not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        500:
          description: Encountered a server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /api-resources/{apiResourceId}/authorization-details-types/{authorizationDetailsTypeId}:
    get:
      tags:
        - API Resource Authorization Details Types
      description: |
        This API is used to retrieve details of a registered authorization details type by a given type ID.
        
        <b>Permission required:</b>  
          * /permission/admin/manage/identity/apiresourcemgt/view  
        
        <b>Scope required:</b>  
          * internal_api_resource_view
      summary: Returns a registered authorization details type by type ID
      operationId: getAuthorizationDetailsType
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
        - $ref: '#/components/parameters/authorizationDetailsTypeId'
      responses:
        200:
          description: Successfully retrieved an authorization details type by type ID
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AuthorizationDetailsTypesGetModel"
        401:
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        404:
          description: Requested resource is not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        500:
          description: Encountered a server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    patch:
      tags:
        - API Resource Authorization Details Types
      description: |
        This API is used to update a registered authorization details type by a given type ID.
        
        <b>Permission required:</b>  
          * /permission/admin/manage/identity/apiresourcemgt/update  
        
        <b>Scope required:</b>  
          * internal_api_resource_update
      summary: Updates a registered authorization details type by type ID
      operationId: updateAuthorizationDetailsType
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
        - $ref: '#/components/parameters/authorizationDetailsTypeId'
      requestBody:
        content:
          "application/json":
            schema:
              $ref: "#/components/schemas/AuthorizationDetailsTypesCreationModel"
      responses:
        204:
          description: No Content
        401:
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        404:
          description: Requested resource is not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        500:
          description: Encountered a server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    delete:
      tags:
        - API Resource Authorization Details Types
      description: |
        This API is used to delete a registered authorization details type by a given type ID.
        
        <b>Permission required:</b>  
          * /permission/admin/manage/identity/apiresourcemgt/delete  
        
        <b>Scope required:</b>  
          * internal_api_resource_delete
      summary: Deletes a registered authorization details type by type ID
      operationId: deleteAuthorizationDetailsType
      parameters:
        - $ref: '#/components/parameters/apiResourceId'
        - $ref: '#/components/parameters/authorizationDetailsTypeId'
      responses:
        204:
          description: Successfully deleted an authorization details type by type ID
        401:
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        500:
          description: Encountered a server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /authorization-details-types:
    get:
      tags:
        - API Resource Authorization Details Types
      summary: Gets all authorization details types in the tenant
      description: >
        Get all authorization details types in the tenant
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/view <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_view
      parameters:
        - name: filter
          in: query
          required: false
          description: |
            Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations.
          schema:
            type: string
          example: type+eq+payment_initiation
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AuthorizationDetailsTypesGetModel'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        404:
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    head:
      tags:
        - API Resource Authorization Details Types
      description: |
        This API is used to check a registered authorization details type's existence using a given type in the tenant.
        
        <b>Permission required:</b>  
          * /permission/admin/manage/identity/apiresourcemgt/view  
        
        <b>Scope required:</b>  
          * internal_api_resource_view
      summary: Checks an authorization details type existence by type in the tenant
      operationId: isAuthorizationDetailsTypeExists
      parameters:
        - name: filter
          in: query
          required: true
          description: |
            Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations.
          schema:
            type: string
          example: type+eq+payment_initiation
      responses:
        200:
          description: Provided authorization details type exists
        401:
          description: Unauthorized request
        404:
          description: Requested resource is not found
        500:
          description: Encountered a server error

  /meta/api-resource-collections:
    get:
      tags:
        - API Resource Collections
      summary: List all API resource collections in the server
      description: >
        List all API resource collections in the server
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/view <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_view
      operationId: getAPIResourceCollections
      parameters:
        - $ref: '#/components/parameters/collectionFilter'
        - $ref: '#/components/parameters/collectionAttributes'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIResourceCollectionListResponse'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /meta/api-resource-collections/{collectionId}:
    get:
      tags:
        - API Resource Collections
      summary: Get API resource collection specified by the id
      description: >
        Get API resource collection specified by the id
        <b>Permission required:</b> <br>
          * /permission/admin/manage/identity/apiresourcemgt/view <br>
        <b>Scope required:</b> <br>
          * internal_api_resource_view
      operationId: getAPIResourceCollectionByCollectionId
      parameters:
        - $ref: '#/components/parameters/collectionId'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIResourceCollectionResponse'
        401:
          description: Unauthorized
        403:
          description: Forbidden
        500:
          description: Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

components:
  parameters:
    organizationId:
      in: path
      name: organizationId
      description: uuid of the org.
      required: true
      schema:
        type: string
        example: "1234-4567-4567"

    apiResourceId:
      name: apiResourceId
      in: path
      description: ID of the API Resource.
      required: true
      schema:
        type: string
        example: er34-gf23-bv54-vb90

    collectionId:
      name: collectionId
      in: path
      description: ID of the API Resource Collection.
      required: true
      schema:
        type: string
        example: er34-gf23-bv54-vb90

    scopeName:
      name: scopeName
      in: path
      description: Name of the Scope.
      required: true
      schema:
        type: string

    scopeId:
      name: scopeId
      in: path
      description: Id of the Scope.
      required: true
      schema:
        type: string

    applicationId:
      name: applicationId
      in: path
      description: ID of the Application.
      required: true
      schema:
        type: string

    authorizationId:
      name: authorizationId
      in: path
      description: ID of the authorization.
      required: true
      schema:
        type: string

    before:
      name: before
      in: query
      required: false
      description: |
        Base64 encoded cursor value for backward pagination.
      schema:
        type: string
      example: Ng==

    after:
      name: after
      in: query
      required: false
      description: |
        Base64 encoded cursor value for forward pagination.
      schema:
        type: string
      example: Ng==

    filter:
      name: filter
      in: query
      required: false
      description: |
        Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations.
      schema:
        type: string
      example: identifier+eq+greetings

    collectionFilter:
      name: filter
      in: query
      required: false
      description: |
        Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations.
      schema:
        type: string
      example: type+eq+tenant

    limit:
      name: limit
      in: query
      required: false
      description: |
        Maximum number of records to return.
      schema:
        type: integer
      example: 10

    attributes:
      name: attributes
      in: query
      required: false
      description: Specifies the required attributes in the response. Only 'properties' attribute is currently supported.
      schema:
        type: string

    collectionAttributes:
      name: attributes
      in: query
      required: false
      description: Specifies the required attributes in the response. Only 'apiResources' attribute is currently supported.
      schema:
        type: string

    authorizationDetailsTypeId:
      name: authorizationDetailsTypeId
      in: path
      description: The ID of the authorization details type that is to be retrieved
      required: true
      schema:
        type: string
        example: a9403470-dd11-46b4-8db9-aaa31f1d4423

  schemas:
    Error:
      type: object
      properties:
        code:
          type: string
          example: AAA-00000
        message:
          type: string
          example: Some Error Message
        description:
          type: string
          example: Some Error Description
        traceId:
          type: string
          example: e0fbcfeb-3617-43c4-8dd0-7b7d38e13047

    APIResourceListItem:
      type: object
      required:
        - id
        - name
        - identifier
        - self
      properties:
        id:
          type: string
          example: gh43-jk34-vb34-df67
        name:
          type: string
          example: Greetings API
        identifier:
          type: string
          example: greetings_api
        type:
          type: string
          example: SYSTEM
        requiresAuthorization:
          type: boolean
          example: true
        properties:
          type: array
          items:
            $ref: '#/components/schemas/Property'
        self:
          type: string
          example: /t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg

    APIResourceResponse:
      type: object
      required:
        - id
        - name
        - identifier
        - self
      properties:
        id:
          type: string
          example: gh43-jk34-vb34-df67
        name:
          type: string
          example: Greetings API
        description:
          type: string
          example: Greeting API representation
        identifier:
          type: string
          example: greetings_api
        type:
          type: string
          example: SYSTEM
        requiresAuthorization:
          type: boolean
          example: true
        scopes:
          type: array
          items:
            $ref: '#/components/schemas/ScopeGetModel'
        authorizationDetailsTypes:
          type: array
          items:
            $ref: '#/components/schemas/AuthorizationDetailsTypesGetModel'
        subscribedApplications:
          type: array
          items:
            $ref: '#/components/schemas/SubscribedApplicationGetModel'
        properties:
          type: array
          items:
            $ref: '#/components/schemas/Property'
        self:
          type: string
          example: /t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg

    APIResourceCreationModel:
      type: object
      required:
        - identifier
        - name
      properties:
        name:
          type: string
          example: Greetings API
        identifier:
          type: string
          example: greetings_api
        description:
          type: string
          example: Greetings API representation
        requiresAuthorization:
          type: boolean
          example: true
        scopes:
          type: array
          items:
            $ref: '#/components/schemas/ScopeCreationModel'
        authorizationDetailsTypes:
          type: array
          items:
            $ref: '#/components/schemas/AuthorizationDetailsTypesCreationModel'
        resourceType:
          type: string
          example: MCP

    APIResourcePatchModel:
      type: object
      properties:
        name:
          type: string
          example: Greetings API
        description:
          type: string
          example: Greetings API representation
        addedScopes:
          type: array
          items:
            $ref: '#/components/schemas/ScopeCreationModel'
        removedScopes:
          type: array
          items:
            type: string
          description: This field is not supported yet.
        addedAuthorizationDetailsTypes:
          type: array
          items:
            $ref: '#/components/schemas/AuthorizationDetailsTypesCreationModel'
        removedAuthorizationDetailsTypes:
          type: array
          items:
            type: string

    PaginationLink:
      type: object
      properties:
        rel:
          type: string
          example: before
        href:
          type: string
          example: /api/server/v1/api-resources?after=NDoy

    APIResourceListResponse:
      type: object
      required:
        - links
      properties:
        totalResults:
          type: integer
          example: 1
        links:
          type: array
          items:
            $ref: '#/components/schemas/PaginationLink'
        APIResources:
          type: array
          items:
            $ref: '#/components/schemas/APIResourceListItem'

    APIResourceMap:
      type: object
      properties:
        read:
          type: array
          items:
            $ref: '#/components/schemas/APIResourceCollectionItem'
        write:
          type: array
          items:
            $ref: '#/components/schemas/APIResourceCollectionItem'

    APIResourceCollectionListItem:
      type: object
      required:
        - id
        - name
        - displayName
        - self
      properties:
        id:
          type: string
          example: gh43-jk34-vb34-df67
        name:
          type: string
          example: bulkUserImport
        displayName:
          type: string
          example: Bulk User Import
        type:
          type: string
          example: SYSTEM
        apiResources:
          $ref: '#/components/schemas/APIResourceMap'
        self:
          type: string
          example: /t/carbon.super/api/server/v1/api-resource-collections/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg

    APIResourceCollectionListResponse:
      type: object
      required:
        - totalResults
        - apiResourceCollections
      properties:
        totalResults:
          type: integer
          example: 1
        apiResourceCollections:
          type: array
          items:
            $ref: '#/components/schemas/APIResourceCollectionListItem'

    APIResourceCollectionItem:
      type: object
      required:
        - id
        - name
        - displayName
        - self
      properties:
        id:
          type: string
          example: gh43-jk34-vb34-df67
        name:
          type: string
          example: Greetings API
        description:
          type: string
          example: Greeting API representation
        identifier:
          type: string
          example: greetings_api
        type:
          type: string
          example: SYSTEM
        scopes:
          type: array
          items:
            $ref: '#/components/schemas/ScopeGetModel'
        self:
          type: string
          example: /t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg

    APIResourceCollectionResponse:
      type: object
      required:
        - id
        - name
        - displayName
      properties:
        id:
          type: string
          example: gh43-jk34-vb34-df67
        name:
          type: string
          example: bulkUserImport
        displayName:
          type: string
          example: Bulk User Import
        type:
          type: string
          example: SYSTEM
        apiResources:
          $ref: '#/components/schemas/APIResourceMap'

    ScopeGetModel:
      type: object
      required:
        - id
        - displayName
        - name
      properties:
        id:
          type: string
          example: sf23-fg34-fy53-hj23
        displayName:
          type: string
          example: Write
        name:
          type: string
          example: greetings:write
        description:
          type: string
          example: Allow writing greetings

    ScopeCreationModel:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          example: 'greetings:write'
        displayName:
          type: string
          example: "Write Greetings"
        description:
          type: string
          example: "Allows writing greetings"

    ScopePatchModel:
      type: object
      properties:
        displayName:
          type: string
          example: "Write Greetings"
        description:
          type: string
          example: "Allows writing greetings"

    SubscribedApplicationGetModel:
      type: object
      properties:
        name:
          type: string
          example: Application1
        id:
          type: string
          example: 23fd-23gd-54vv-sdhf

    Property:
      type: object
      required:
        - name
        - value
      properties:
        name:
          type: string
          example: "label"
        value:
          type: string
          example: "Internal"

    AuthorizationDetailsTypesCreationModel:
      type: object
      required:
        - type
        - name
        - description
        - schema
      properties:
        type:
          type: string
          example: payment_initiation
          description: an unique type of the authorization details type
          minLength: 1
          maxLength: 255
        name:
          type: string
          minLength: 3
          maxLength: 255
          description: display name of the authorization details type
          example: Payment Initiation
        description:
          type: string
          description: description of the authorization details type
          example: Payment initiation authorization details type
        schema:
          type: object
          additionalProperties: true
          description: Accepts the [JSON Schema document](https://json-schema.org/draft/2020-12/json-schema-core#name-json-schema-documents) of the authorization details type
          example:
            type: object
            required:
              - type
              - actions
              - locations
              - instructedAmount
            properties:
              type:
                type: string
                enum:
                  - payment_initiation
              actions:
                type: array
                items:
                  type: string
                  enum:
                    - initiate
                    - cancel
              locations:
                type: array
                items:
                  type: string
                  format: uri
              instructedAmount:
                type: object
                properties:
                  currency:
                    type: string
                    minLength: 3
                  amount:
                    type: string
              creditorName: string
              creditorAccount:
                type: object

    AuthorizationDetailsTypesGetModel:
      allOf:
        - type: object
          required:
            - id
          properties:
            id:
              type: string
              example: a9403470-dd11-46b4-8db9-aaa31f1d4423
              description: an unique id of the registered authorization details type
              minLength: 36
              maxLength: 36
        - $ref: "#/components/schemas/AuthorizationDetailsTypesCreationModel"

  responses:
    BadRequest:
      description: Bad Request. Invalid request or validation error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 400
            message: Bad Request
            description: Invalid request or validation error

    Conflict:
      description: Conflict. Specified resource already exists.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 409
            message: Conflict
            description: Specified resource already exists
            moreInfo: ''
            error: []
    Forbidden:
      description: >-
        Forbidden. The request must be conditional but no condition has been
        specified.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 403
            message: Forbidden
            description: >-
              The request must be conditional but no condition has been
              specified
    InternalServerError:
      description: Internal Server Error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 500
            message: Internal Server Error
            description: >-
              The server encountered an internal error. Please contact
              administrator.
            moreInfo: ''
            error: []
    NotFound:
      description: Not Found. The specified resource does not exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 404
            message: Not Found
            description: The specified resource does not exist
            moreInfo: ''
            error: []

    Unauthorized:
      description: Unauthorized. The user is not authorized.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 401
            message: Unauthorized
            description: The user is not authorized
            moreInfo: ''
            error: []

  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: 'https://localhost:9443/oauth2/authorize'
          tokenUrl: 'http://localhost:9443/oauth2/token'
          scopes: {}
