openapi: 3.0.0
info:
  title: Hello Michelin API
  description: This API has been created for Demo purpose API Hello Michelin.
  version: 1.0.0
  contact:
    name: API Team
    email: devportal.support@michelin.com
servers:
  - url: https://api.michelin.com/p0r/v1
    description: Production
tags:
  - name: Hello Michelin API

paths:
  /hello-michelin/keyless:
    get:
      tags:
        - Hello Michelin API
      summary: Returns Hello Michelin (Keyless)
      description: Generates a hello-michelin response without any authentication.
      operationId: generate-hello-michelin-keyless
      responses:
        '200':
          description: Successful response with Hello Michelin
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: "Hello Michelin from Keyless"
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse404'
        '429':
          description: Quota or Spike Arrest Violation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitErrorResponse429'

  /hello-michelin/apikey:
    get:
      tags:
        - Hello Michelin API
      summary: Returns Hello Michelin (API Key)
      description: Generates a hello-michelin response using API Key.
      operationId: generate-hello-michelin-apikey
      parameters:
        - name: apikey
          in: header
          required: true
          schema:
            type: string
            example: "YOUR_MICHELIN_API_KEY"
          description: The API Key to access the API.
      responses:
        '200':
          description: Successful response with Hello Michelin
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: "Hello Michelin from API Key"
        '401':
          description: Unauthorized - Authentication failed or was not provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse401'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse404'
        '429':
          description: Quota or Spike Arrest Violation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitErrorResponse429'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse500'

  /internal/oauth/token/accesstoken:
    post:
      tags:
        - Hello Michelin API
      summary: Obtain an OAuth Access Token
      description: Generates an access token using client credentials.
      operationId: obtain-access-token
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                client_id:
                  type: string
                  description: Your client identifier
                  example: "YOUR_MICHELIN_CLIENT_ID"
                client_secret:
                  type: string
                  description: Your client secret
                  example: "YOUR_MICHELIN_CLIENT_SECRET"
              required:
                - client_id
                - client_secret
      responses:
        '200':
          description: Successful response with access token
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_token:
                    type: string
                    example: "YOUR_ACCESS_TOKEN"
                  token_type:
                    type: string
                    example: "Bearer"
                  expires_in:
                    type: integer
                    example: 3600
        '400':
          description: Bad Request - Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse400'
        '401':
          description: Unauthorized - Authentication failed or was not provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse401'

  /hello-michelin/oauth:
    get:
      tags:
        - Hello Michelin API
      summary: Returns Hello Michelin (OAuth2)
      description: Generates a hello-michelin response using OAuth2.
      operationId: generate-hello-michelin-oauth
      security:
        - OAuth2: []
      responses:
        '200':
          description: Successful response with Hello Michelin
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: "Hello Michelin from OAuth2"
        '401':
          description: Unauthorized - Authentication failed or was not provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse401'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse404'
        '429':
          description: Quota or Spike Arrest Violation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitErrorResponse429'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse500'

components:
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: "https://api.michelin.com/idp/v1/internal/oauth/token/accesstoken"
          scopes: {}

  schemas:
    ErrorResponse401:
      type: object
      properties:
        message:
          type: string
          example: "Unauthorized request"
        http_status_code:
          type: integer
          example: 401

    ErrorResponse404:
      type: object
      properties:
        message:
          type: string
          example: "URL Not found"
        http_status_code:
          type: integer
          example: 404

    RateLimitErrorResponse429:
      type: object
      properties:
        message:
          type: string
          description: "Message describing the rate limiting error"
          example: "Spike limit exceeded! You reached the limit of requests allowed in a specific time frame."
        http_status_code:
          type: integer
          example: 429
        violation_type:
          type: string
          example: "Quota Violation"
          description: "Specifies the type of violation (e.g., Spike Arrest, Quota Violation)"

    ErrorResponse500:
      type: object
      properties:
        message:
          type: string
          example: "Server unavailable"
        http_status_code:
          type: integer
          example: 500

    ErrorResponse400:
      type: object
      properties:
        message:
          type: string
          example: "Invalid request"
        http_status_code:
          type: integer
          example: 400
