openapi: 3.0.0
info:
  title: 'Vegan-Inspector API'
  description: 'API for checking if products are vegan'
  version: 1.0.0
servers:
  -
    url: 'https://api.vegan-inspector.app/v0'
    description: 'Production server'
paths:
  '/products/{barcode}':
    get:
      tags:
        - Products
      operationId: getData
      parameters:
        -
          name: barcode
          in: path
          description: 'Product barcode'
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 'Product information'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
        '400':
          description: 'Invalid barcode'
        '404':
          description: 'Product not found'
components:
  schemas:
    Image:
      properties:
        url:
          type: string
          example: 'https://example.com/image.jpg'
          nullable: true
        timestamp:
          type: integer
          example: 1640995200
          nullable: true
        license:
          $ref: '#/components/schemas/ImageLicense'
      type: object
    ImageLicense:
      required:
        - name
        - url
      properties:
        name:
          type: string
          example: 'CC BY-SA 3.0'
        url:
          type: string
          example: 'https://creativecommons.org/licenses/by-sa/3.0/'
      type: object
    Ingredient:
      required:
        - name
        - vegan
        - vegetarian
      properties:
        name:
          type: string
          example: Water
          nullable: true
        vegan:
          oneOf:
            -
              $ref: '#/components/schemas/VegStatus'
          nullable: true
          type: VegStatus
          enum:
            - 'yes'
            - 'no'
            - maybe
            - unknown
          example: 'no'
        vegetarian:
          oneOf:
            -
              $ref: '#/components/schemas/VegStatus'
          nullable: true
          type: VegStatus
          enum:
            - 'yes'
            - 'no'
            - maybe
            - unknown
          example: 'yes'
      type: object
    Labels:
      properties:
        ecoScore:
          type: string
          example: A
          nullable: true
        novaScore:
          type: integer
          maximum: 4
          minimum: 1
          example: 1
          nullable: true
        nutriScore:
          type: string
          example: A
          nullable: true
      type: object
    LastSourceChange:
      required:
        - lastEditor
        - lastModified
        - lastUpdated
      properties:
        lastEditor:
          type: string
          example: openfoodfacts-contributors
        lastModified:
          type: integer
          example: 1640995200
        lastUpdated:
          type: integer
          example: 1640995200
      type: object
    Product:
      required:
        - name
        - brand
        - vegan
        - vegetarian
        - image
        - labels
        - sources
        - ingredients
      properties:
        name:
          type: string
          example: 'Vegan Burger'
        brand:
          type: string
          example: 'Beyond Meat'
        vegan:
          $ref: '#/components/schemas/VegStatus'
        vegetarian:
          $ref: '#/components/schemas/VegStatus'
        image:
          $ref: '#/components/schemas/Image'
        labels:
          $ref: '#/components/schemas/Labels'
        sources:
          type: array
          items:
            $ref: '#/components/schemas/Source'
        ingredients:
          type: array
          items:
            $ref: '#/components/schemas/Ingredient'
      type: object
    Source:
      required:
        - provider
        - sourceUrl
        - license
        - licenseUrl
        - lastChange
      properties:
        provider:
          type: string
          example: 'Open Food Facts'
        sourceUrl:
          type: string
          example: 'https://world.openfoodfacts.org/product/123456'
        license:
          type: string
          example: 'ODbL 1.0'
        licenseUrl:
          type: string
          example: 'https://opendatacommons.org/licenses/odbl/1.0/'
        lastChange:
          $ref: '#/components/schemas/LastSourceChange'
      type: object
    VegStatus:
      type: string
      enum:
        - 'Yes'
        - Maybe
        - Unknown
        - 'No'
tags:
  -
    name: Products
    description: Products
