openapi: 3.0.3
info:
  title: Repzo API - Variant
  version: 1.0.0
  description: OpenAPI specification for Repzo Variant endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /variant:
    get:
      summary: Find variants
      operationId: findVariants
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering variants
      responses:
        "200":
          description: A list of variants
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VariantFindResult"
    post:
      summary: Create a variant
      operationId: createVariant
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VariantCreateBody"
      responses:
        "201":
          description: Variant created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VariantCreateResult"
  /variant/{id}:
    get:
      summary: Get a variant by ID
      operationId: getVariant
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Variant details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VariantGetResult"
    put:
      summary: Update a variant
      operationId: updateVariant
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VariantUpdateBody"
      responses:
        "200":
          description: Variant updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VariantUpdateResult"
    delete:
      summary: Remove a variant
      operationId: removeVariant
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Variant removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VariantRemoveResult"
components:
  schemas:
    VariantFindResult:
      type: object
      description: Result of finding variants
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/VariantSchema"
        total_result:
          type: number
          description: Total number of variants
        current_count:
          type: number
          description: Count of variants 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 variants 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
    VariantSchema:
      type: object
      description: Variant schema
      properties:
        _id:
          type: string
          description: Unique identifier for the variant
        name:
          type: string
          description: Name of the variant
        product:
          type: string
          description: ID of the product this variant belongs to
        price:
          type: number
          description: Price of the variant
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the variant is disabled
        uuid:
          type: string
          description: UUID for the variant
        local_name:
          type: string
          description: Localized name of the variant
        sku:
          type: string
          description: Stock keeping unit
        barcode:
          type: string
          description: Barcode of the variant
        weight:
          type: number
          description: Weight of the variant
        length:
          type: number
          description: Length of the variant
        width:
          type: number
          description: Width of the variant
        height:
          type: number
          description: Height of the variant
        position:
          type: number
          description: Position of the variant
        default:
          type: boolean
          description: Whether this is the default variant
        variant_img:
          type: string
          description: Image URL for the variant
        modifiers_groups:
          type: array
          items:
            type: string
          description: Modifier groups for the variant
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        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
    VariantCreateBody:
      type: object
      description: Body for creating a variant
      required:
        - name
        - product
        - price
      properties:
        name:
          type: string
          description: Name of the variant
        product:
          type: string
          description: ID of the product this variant belongs to
        price:
          type: number
          description: Price of the variant
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the variant is disabled
        uuid:
          type: string
          description: UUID for the variant
        local_name:
          type: string
          description: Localized name of the variant
        sku:
          type: string
          description: Stock keeping unit
        barcode:
          type: string
          description: Barcode of the variant
        weight:
          type: number
          description: Weight of the variant
        length:
          type: number
          description: Length of the variant
        width:
          type: number
          description: Width of the variant
        height:
          type: number
          description: Height of the variant
        position:
          type: number
          description: Position of the variant
        default:
          type: boolean
          description: Whether this is the default variant
        variant_img:
          type: string
          description: Image URL for the variant
        modifiers_groups:
          type: array
          items:
            type: string
          description: Modifier groups for the variant
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    VariantCreateResult:
      type: object
      description: Result of creating a variant
      properties:
        $ref: "#/components/schemas/VariantSchema"
    VariantGetResult:
      $ref: "#/components/schemas/VariantSchema"
      description: Result of getting a variant
    VariantUpdateBody:
      type: object
      description: Body for updating a variant
      properties:
        name:
          type: string
          description: Name of the variant
        product:
          type: string
          description: ID of the product this variant belongs to
        price:
          type: number
          description: Price of the variant
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the variant is disabled
        uuid:
          type: string
          description: UUID for the variant
        local_name:
          type: string
          description: Localized name of the variant
        sku:
          type: string
          description: Stock keeping unit
        barcode:
          type: string
          description: Barcode of the variant
        weight:
          type: number
          description: Weight of the variant
        length:
          type: number
          description: Length of the variant
        width:
          type: number
          description: Width of the variant
        height:
          type: number
          description: Height of the variant
        position:
          type: number
          description: Position of the variant
        default:
          type: boolean
          description: Whether this is the default variant
        variant_img:
          type: string
          description: Image URL for the variant
        modifiers_groups:
          type: array
          items:
            type: string
          description: Modifier groups for the variant
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        _id:
          type: string
          description: Unique identifier for the variant
        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
    VariantUpdateResult:
      $ref: "#/components/schemas/VariantSchema"
      description: Result of updating a variant
    VariantRemoveResult:
      $ref: "#/components/schemas/VariantSchema"
      description: Result of removing a variant
