openapi: 3.0.3
info:
  title: Repzo API - Tag
  version: 1.0.0
  description: OpenAPI specification for Repzo Tag endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /tag:
    get:
      summary: Find tags
      operationId: findTags
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              _id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              search:
                type: string
              name:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              disabled:
                type: boolean
              from_updatedAt:
                type: number
              from__id:
                type: string
              to__id:
                type: string
              sortBy:
                type: array
                items:
                  type: object
                  properties:
                    field:
                      type: string
                      enum: [_id]
                    type:
                      type: string
                      enum: [asc, desc]
          description: Query parameters for filtering tags
      responses:
        "200":
          description: A list of tags
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TagFindResult"
    post:
      summary: Create a tag
      operationId: createTag
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TagCreateBody"
      responses:
        "201":
          description: Tag created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TagCreateResult"
  /tag/{id}:
    get:
      summary: Get a tag by ID
      operationId: getTag
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Tag details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TagGetResult"
    put:
      summary: Update a tag
      operationId: updateTag
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TagUpdateBody"
      responses:
        "200":
          description: Tag updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TagUpdateResult"
    delete:
      summary: Remove a tag
      operationId: removeTag
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Tag removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TagRemoveResult"
components:
  schemas:
    TagFindResult:
      type: object
      description: Result of finding tags
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/TagSchema"
        total_result:
          type: number
          description: Total number of tags
        current_count:
          type: number
          description: Count of tags in current page
        total_pages:
          type: number
          description: Total number of pages
        current_page:
          type: number
          description: Current page number
        per_page:
          type: number
          description: Number of tags per page
        first_page_url:
          type: string
          description: URL for the first page
        last_page_url:
          type: string
          description: URL for the last page
        next_page_url:
          type: string
          nullable: true
          description: URL for the next page
        prev_page_url:
          type: string
          nullable: true
          description: URL for the previous page
        path:
          type: string
          description: Base URL path
    TagSchema:
      type: object
      description: Tag schema
      properties:
        _id:
          type: string
          description: Unique identifier for the tag
        name:
          type: string
          description: Name of the tag
        disabled:
          type: boolean
          description: Whether the tag is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
        __v:
          type: number
          description: Version number
    TagCreateBody:
      type: object
      description: Body for creating a tag
      required:
        - name
        - company_namespace
      properties:
        name:
          type: string
          description: Name of the tag
        disabled:
          type: boolean
          description: Whether the tag is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
    TagCreateResult:
      $ref: "#/components/schemas/TagSchema"
      description: Result of creating a tag
    TagGetResult:
      $ref: "#/components/schemas/TagSchema"
      description: Result of getting a tag
    TagUpdateBody:
      type: object
      description: Body for updating a tag
      properties:
        name:
          type: string
          description: Name of the tag
        disabled:
          type: boolean
          description: Whether the tag is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        _id:
          type: string
          description: Unique identifier for the tag
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
        __v:
          type: number
          description: Version number
    TagUpdateResult:
      $ref: "#/components/schemas/TagSchema"
      description: Result of updating a tag
    TagRemoveResult:
      $ref: "#/components/schemas/TagSchema"
      description: Result of removing a tag
