openapi: 3.0.3
info:
  title: Repzo API - SubCategory
  version: 1.0.0
  description: OpenAPI specification for Repzo SubCategory endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /product/sub-categories:
    get:
      summary: Find subcategories
      operationId: findSubCategories
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              populatedKeys:
                type: array
                items:
                  type: string
                  enum: [parent_id]
              _id:
                type: array
                items:
                  type: string
              search:
                type: string
              name:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              local_name:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              parent_id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              disabled:
                type: boolean
              position:
                oneOf:
                  - type: array
                    items:
                      type: number
                  - type: number
              from_updatedAt:
                type: number
              createdAt:
                type: number
              updatedAt:
                type: number
              withProduct:
                type: boolean
              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 subcategories
      responses:
        "200":
          description: A list of subcategories
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SubCategoryFindResult"
    post:
      summary: Create a subcategory
      operationId: createSubCategory
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SubCategoryCreateBody"
      responses:
        "201":
          description: SubCategory created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SubCategoryCreateResult"
  /product/sub-categories/{id}:
    get:
      summary: Get a subcategory by ID
      operationId: getSubCategory
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
        - in: query
          name: params
          schema:
            type: object
            properties:
              populatedKeys:
                type: array
                items:
                  type: string
                  enum: [parent_id]
      responses:
        "200":
          description: SubCategory details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SubCategoryGetResult"
    put:
      summary: Update a subcategory
      operationId: updateSubCategory
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SubCategoryUpdateBody"
      responses:
        "200":
          description: SubCategory updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SubCategoryUpdateResult"
    delete:
      summary: Remove a subcategory
      operationId: removeSubCategory
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: SubCategory removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SubCategoryRemoveResult"
components:
  schemas:
    SubCategoryFindResult:
      type: object
      description: Result of finding subcategories
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/SubCategorySchema"
        total_result:
          type: number
          description: Total number of subcategories
        current_count:
          type: number
          description: Count of subcategories 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 subcategories 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
    SubCategorySchema:
      type: object
      description: SubCategory schema
      properties:
        _id:
          type: string
          description: Unique identifier for the subcategory
        name:
          type: string
          description: Name of the subcategory
        parent_id:
          oneOf:
            - type: string
              description: ID of the parent category
            - type: object
              properties:
                _id:
                  type: string
                  description: ID of the parent category
                name:
                  type: string
                  description: Name of the parent category
              description: Parent category object when populated
        local_name:
          type: string
          description: Localized name of the subcategory
        disabled:
          type: boolean
          description: Whether the subcategory is disabled
        photo:
          type: string
          description: Photo URL of the subcategory
        position:
          type: number
          description: Position of the subcategory
        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
    SubCategoryCreateBody:
      type: object
      description: Body for creating a subcategory
      required:
        - name
        - parent_id
      properties:
        name:
          type: string
          description: Name of the subcategory
        parent_id:
          type: string
          description: ID of the parent category
        local_name:
          type: string
          description: Localized name of the subcategory
        disabled:
          type: boolean
          description: Whether the subcategory is disabled
        photo:
          type: string
          description: Photo URL of the subcategory
        position:
          type: number
          description: Position of the subcategory
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    SubCategoryCreateResult:
      $ref: "#/components/schemas/SubCategorySchema"
      description: Result of creating a subcategory
    SubCategoryGetResult:
      $ref: "#/components/schemas/SubCategorySchema"
      description: Result of getting a subcategory
    SubCategoryUpdateBody:
      type: object
      description: Body for updating a subcategory
      properties:
        name:
          type: string
          description: Name of the subcategory
        parent_id:
          type: string
          description: ID of the parent category
        local_name:
          type: string
          description: Localized name of the subcategory
        disabled:
          type: boolean
          description: Whether the subcategory is disabled
        photo:
          type: string
          description: Photo URL of the subcategory
        position:
          type: number
          description: Position of the subcategory
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        _id:
          type: string
          description: Unique identifier for the subcategory
        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
    SubCategoryUpdateResult:
      $ref: "#/components/schemas/SubCategorySchema"
      description: Result of updating a subcategory
    SubCategoryRemoveResult:
      $ref: "#/components/schemas/SubCategorySchema"
      description: Result of removing a subcategory
