openapi: 3.1.0
info:
  title: QR Code Generator API
  version: 0.1.0
  description: Public QR code generation API for direct image and JSON clients.
servers:
  - url: https://qrcode-generator.sautergroup.com/api
paths:
  /health:
    get:
      summary: Health check
      responses:
        "200":
          description: Service is healthy
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    const: ok
  /qr:
    get:
      summary: Generate a QR code from query text
      parameters:
        - name: text
          in: query
          required: true
          schema:
            type: string
        - name: format
          in: query
          schema:
            type: string
            enum: [png, svg]
            default: png
        - name: size
          in: query
          schema:
            type: integer
            default: 512
        - name: margin
          in: query
          schema:
            type: integer
            default: 4
        - name: ecc
          in: query
          schema:
            type: string
            enum: [L, M, Q, H]
            default: M
      responses:
        "200":
          description: QR image
          content:
            image/png:
              schema:
                type: string
                format: binary
            image/svg+xml:
              schema:
                type: string
        "400":
          $ref: "#/components/responses/Error"
    post:
      summary: Generate a QR code from a structured request
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/QRRequest"
      responses:
        "200":
          description: QR image
          content:
            image/png:
              schema:
                type: string
                format: binary
            image/svg+xml:
              schema:
                type: string
        "400":
          $ref: "#/components/responses/Error"
  /qr/vcard:
    get:
      summary: Generate a vCard QR code from query fields
      parameters:
        - name: fullName
          in: query
          required: true
          schema:
            type: string
        - name: title
          in: query
          schema:
            type: string
        - name: company
          in: query
          schema:
            type: string
        - name: department
          in: query
          schema:
            type: string
        - name: email
          in: query
          schema:
            type: string
        - name: mobilePhone
          in: query
          schema:
            type: string
        - name: city
          in: query
          schema:
            type: string
        - name: postalCode
          in: query
          schema:
            type: string
        - name: officeLocation
          in: query
          schema:
            type: string
      responses:
        "200":
          description: QR image
          content:
            image/png:
              schema:
                type: string
                format: binary
            image/svg+xml:
              schema:
                type: string
        "400":
          $ref: "#/components/responses/Error"
    post:
      summary: Generate a vCard QR code from a JSON request
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VCardRequest"
      responses:
        "200":
          description: QR image
          content:
            image/png:
              schema:
                type: string
                format: binary
            image/svg+xml:
              schema:
                type: string
        "400":
          $ref: "#/components/responses/Error"
components:
  responses:
    Error:
      description: Validation or generation error
      content:
        application/json:
          schema:
            type: object
            properties:
              request_id:
                type: string
              error:
                type: string
  schemas:
    QRRequest:
      type: object
      required: [type, data]
      properties:
        type:
          type: string
          enum: [text, url, email, phone, sms, wifi, vcard]
        data:
          type: object
        options:
          $ref: "#/components/schemas/QROptions"
    VCardRequest:
      type: object
      required: [fullName]
      properties:
        fullName:
          type: string
        title:
          type: string
        company:
          type: string
        department:
          type: string
        email:
          type: string
        mobilePhone:
          type: string
        city:
          type: string
        postalCode:
          type: string
        officeLocation:
          type: string
        options:
          $ref: "#/components/schemas/QROptions"
    QROptions:
      type: object
      properties:
        format:
          type: string
          enum: [png, svg]
          default: png
        size:
          type: integer
          default: 512
        margin:
          type: integer
          default: 4
        ecc:
          type: string
          enum: [L, M, Q, H]
          default: M
