Skip to main content

OpenAPI V3.0 Specification

OpenApi 3.0 specification in Yaml format

contents can be written in separate files, and referenced with $ref: "./schemas/User.yaml" syntax

Example:

# Version of the openapi specificaiton
openapi: 3.0.0
# General metadata about this app
info:
  version: 1.0.0
  title: Simple App
  description: a simple app for demonstration purposes only

# list of backed urls:
servers:
  - url: https://example.io/v1
  - url: http://192.168.1.1/api/v2

# Authentication:
components:
  securityScheme:

    # Basic Authentication
    BasicAuth:
      type: http
      scheme: basic

    # Bearer Authentication
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

  # Templates for "Objects"
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
      required:
        - id
        - name

security:
  - BasicAuth: []

# The endpoints
paths:
  # Example 1: Basic Template
  /artists-e1:
    get: ...    # get an object
    post: ...   # create an object
    put: ...    # update the whole object
    patch: ...  # update some parts of the object
    delete: ... # delete the object
    
  

  # Simple get method
  /artists:
    get:
      # An optional unique string to identify an operation
      operationId: lockerNoteSavePath
      # Tags to organize paths into components
      tags:
        - artists
      # A quick summary
      summary: Save user's locker note
      # A detailed description, also supports markdown
      description: >
        A detailed description of the operation.
        Use markdown for rich text representation,
        such as **bold**, *italic*, and [links](https://swagger.io).
      security:
        - bearerAuth: []
      parameters:
        - $ref: "../../headers/acceptLanguageHeader.yaml"
        - name: noteId
          in: path
          required: true
          schema:
            type: integer
            format: int64
      description: Returns a list of artists
      responses:
        '200':
          description: Successfully returned a list of artists
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  required:
                    - username
                  properties:
                    artist_name:
                      type: string
                    artist_genre:
                      type: string
                    albums_recorded:
                      type: integer
                    username:
                      type: string

        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:   
                  message:
                    type: string