openapi: 3.0.3
info:
  title: Swifty OAuth API
  version: 1.0.0
  description: |
      API for the Swifty OAuth Backend
  contact:
    name: RxFoundry Team
    email: paul.tindall@rxfoundry.com

paths:
  '/token/':
    post:
      tags:
        - OAuth
      summary: Get a token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                grant_type:
                  type: string
                  description: Either 'password' or 'refresh_token'
                username:
                  type: string
                  description: Required if grant_type is 'password'
                password:
                  type: string
                  description: Required if grant_type is 'password'
                refresh_token:
                  type: string
                  description: Required if grant_type is 'refresh_token'
      responses:
        '200':
          description: A token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '400':
          description: Invalid request
      x-openapi-router-controller: swifty_api.controllers.o_auth_controller
      operationId: get_token
      security: []

  '/userinfo/':
    post:
      tags:
        - OAuth
      summary: Get user info
      responses:
        '200':
          description: User info
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserInfoResponse'
        '400':
          description: Invalid request
      x-openapi-router-controller: swifty_api.controllers.o_auth_controller
      operationId: get_user_info
      security:
        - opaque_token: []


components:
  schemas:
    TokenResponse:
      type: object
      properties:
        access_token:
          type: string
        token_type:
          type: string
          default: "Bearer"
        expires_in:
          type: integer
        refresh_token:
          type: string
        scope:
          type: string
          default: "openid"
    UserInfoResponse:
      type: object
      properties:
        sub:
          type: string
        email:
          type: string
        given_name:
          type: string
        family_name:
          type: string
        preferred_username:
          type: string
        name:
          type: string
        permissions:
          type: array
          items:
            type: string
        user_groups:
          type: array
          items:
            type: string
        provider_npi:
          type: string
          description: The NPI of the provider associated with the Swifty user
        provider_uuid:
          type: string
          description: The UUID of the provider associated with the Swifty user
        is_active:
          type: boolean
          description: Whether the Swifty user is active
        is_validated:
          type: boolean
          description: Whether the Swifty user has been validated




