openapi: 3.0.0
info:
  title: TableFlow API
  version: 0.1.1
paths:
  /import/{id}:
    get:
      summary: Returns an import.
      parameters:
        - description: Import ID
          in: path
          name: id
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
  /import/{id}/download:
    get:
      summary: Downloads the import as a CSV file.
      parameters:
        - description: Import ID
          in: path
          name: id
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: OK
          content:
            text/csv: {}
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
  /import/{id}/rows:
    get:
      summary: Paginate the rows of an import
      parameters:
        - description: Import ID
          in: path
          name: id
          required: true
          schema:
            type: string
            format: uuid
        - description: Pagination offset
          in: query
          name: offset
          schema:
            type: integer
            minimum: 0
        - description: Pagination limit
          in: query
          name: limit
          schema:
            type: integer
            minimum: 0
            maximum: 1000
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
  /importer:
    post:
      summary: Create importer
      description: Create an importer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/types.Importer'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/types.Importer'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
  /importer/{id}:
    get:
      summary: Get importer
      description: Get an importer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/types.Importer'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
    put:
      summary: Edit importer
      description: Edit an importer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/types.Importer'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/types.Importer'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
    delete:
      summary: Delete importer
      description: Delete an importer along with all associated objects (template, columns)
      parameters:
        - description: Importer ID
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
components:
  schemas:
    types.Importer:
      properties:
        id:
          example: 6de452a2-bd1f-4cb3-b29b-0f8a2e3d9353
          type: string
        name:
          example: Test Importer
          type: string
        template:
          $ref: '#/components/schemas/types.Template'
      type: object
    types.Pagination:
      properties:
        limit:
          type: integer
        offset:
          type: integer
        total:
          type: integer
      type: object
    types.Res:
      properties:
        error:
          type: string
        message:
          type: string
      type: object
    types.Template:
      properties:
        columns:
          items:
            $ref: '#/components/schemas/types.TemplateColumn'
          type: array
        id:
          example: f0797968-becc-422a-b135-19de1d8c5d46
          type: string
        name:
          example: My Template
          type: string
      type: object
    types.TemplateColumn:
      properties:
        description:
          example: The first name
          type: string
        id:
          example: a1ed136d-33ce-4b7e-a7a4-8a5ccfe54cd5
          type: string
        key:
          example: email
          type: string
        name:
          example: First Name
          type: string
        required:
          example: false
          type: boolean
        suggested_mappings:
          example:
            - first_name
          items:
            type: string
          type: array
        validations:
          items:
            $ref: '#/components/schemas/types.Validation'
          type: array
      type: object
    types.Validation:
      properties:
        id:
          example: 4581
          type: integer
        message:
          example: This column must contain a value
          type: string
        severity:
          example: error
          type: string
        type:
          example: filled
          type: string
        value:
          example: 'true'
          type: string
      type: object
