openapi: 3.1.0
info:
  title: ows-url-shortener
  description: URL Shortener
  version: 1.0.0
servers:
- url: https://qa-url-shortener.theorchard.com
paths:
  /hello/:
    get:
      tags:
      - Infra
      summary: Hello
      operationId: hello
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HelloResponse'
  /check-path:
    get:
      tags:
      - Main
      summary: Check Path
      operationId: checkPath
      parameters:
      - name: path
        in: query
        required: true
        schema:
          type: string
          minLength: 5
          pattern: ^[0-9a-zA-Z-]+$
          title: Path
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckPathResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /redirect/{path}:
    get:
      tags:
      - Main
      summary: Short Url Redirect
      operationId: shortUrlRedirect
      parameters:
      - name: path
        in: path
        required: true
        schema:
          type: string
          title: Path
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /shorten:
    post:
      tags:
      - Main
      summary: Shorten Url
      operationId: shortenUrl
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ShortenRequestBody'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ShortenResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /bulk-shorten:
    post:
      tags:
      - Main
      summary: Bulk Shorten Url
      operationId: bulkShortenUrl
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkShortenRequestBody'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkShortenResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /allowed-domains:
    get:
      tags:
      - Main
      summary: Allowed Domains
      operationId: allowedDomains
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                items:
                  type: string
                type: array
                title: Response Alloweddomains
  /delete-paths:
    post:
      tags:
      - Main
      summary: Delete Paths
      operationId: deletePaths
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeletePathsRequestBody'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /paths/{path}:
    patch:
      tags:
      - Main
      summary: Update Path
      operationId: updatePath
      parameters:
      - name: path
        in: path
        required: true
        schema:
          type: string
          title: Path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePathRequestBody'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    BulkShortenRequestBody:
      properties:
        url:
          type: string
          title: Url
        domain:
          type: string
          title: Domain
        path_length:
          type: integer
          maximum: 15.0
          minimum: 6.0
          title: Path Length
          default: 6
        path_prefix:
          anyOf:
          - type: string
            minLength: 5
            pattern: ^[0-9a-zA-Z-]+$
          - type: 'null'
          title: Path Prefix
        urls_count:
          type: integer
          maximum: 1000.0
          minimum: 1.0
          title: Urls Count
          default: 1
        additional_attributes:
          anyOf:
          - items:
              type: object
            type: array
          - type: 'null'
          title: Additional Attributes
      type: object
      required:
      - url
      - domain
      title: BulkShortenRequestBody
    BulkShortenResponse:
      properties:
        url:
          type: string
          title: Url
        created_at:
          type: string
          format: date-time
          title: Created At
        short_urls:
          items:
            $ref: '#/components/schemas/BulkShortenResponseShortUrl'
          type: array
          title: Short Urls
      type: object
      required:
      - url
      - created_at
      - short_urls
      title: BulkShortenResponse
    BulkShortenResponseShortUrl:
      properties:
        short_url:
          type: string
          title: Short Url
        additional_attributes:
          anyOf:
          - type: object
          - type: 'null'
          title: Additional Attributes
      type: object
      required:
      - short_url
      - additional_attributes
      title: BulkShortenResponseShortUrl
    CheckPathResponse:
      properties:
        is_available:
          type: boolean
          title: Is Available
      type: object
      required:
      - is_available
      title: CheckPathResponse
    DeletePathsRequestBody:
      properties:
        paths:
          items:
            type: string
          type: array
          title: Paths
      type: object
      required:
      - paths
      title: DeletePathsRequestBody
    HTTPValidationError:
      title: HTTPValidationError
      type: object
      properties:
        message:
          title: Message
          type: string
        code:
          title: Error code
          type: string
        fieldErrors:
          title: Field errors
          type: object
          additionalProperties:
            $ref: '#/components/schemas/FieldError'
      required:
      - message
      - code
      - fields
      example:
        message: Invalid input
        code: invalid_input
        fieldErrors:
          name:
            message: Cannot be blank
            code: missing
          email:
            message: Not valid email
            code: invalid_email
    HelloResponse:
      properties:
        status:
          type: string
          title: Status
          default: ok
      type: object
      title: HelloResponse
    ShortenRequestBody:
      properties:
        url:
          type: string
          title: Url
        domain:
          type: string
          title: Domain
        path_length:
          type: integer
          maximum: 15.0
          minimum: 6.0
          title: Path Length
          default: 6
        path:
          anyOf:
          - type: string
            minLength: 5
            pattern: ^[0-9a-zA-Z-]+$
          - type: 'null'
          title: Path
        path_prefix:
          anyOf:
          - type: string
            minLength: 5
            pattern: ^[0-9a-zA-Z-]+$
          - type: 'null'
          title: Path Prefix
        additional_attributes:
          anyOf:
          - type: object
          - type: 'null'
          title: Additional Attributes
      type: object
      required:
      - url
      - domain
      title: ShortenRequestBody
    ShortenResponse:
      properties:
        url:
          type: string
          title: Url
        short_url:
          type: string
          title: Short Url
        created_at:
          type: string
          format: date-time
          title: Created At
        additional_attributes:
          anyOf:
          - type: object
          - type: 'null'
          title: Additional Attributes
      type: object
      required:
      - url
      - short_url
      - created_at
      - additional_attributes
      title: ShortenResponse
    UpdatePathRequestBody:
      properties:
        url:
          anyOf:
          - type: string
          - type: 'null'
          title: Url
        domain:
          anyOf:
          - type: string
          - type: 'null'
          title: Domain
        additional_attributes:
          anyOf:
          - type: object
          - type: 'null'
          title: Additional Attributes
      type: object
      title: UpdatePathRequestBody
    FieldError:
      title: FieldError
      type: object
      properties:
        message:
          title: Message
          type: string
        code:
          title: Error code
          type: string
      required:
      - message
      - code
