Skip to content

Instantly share code, notes, and snippets.

@MarwanRefaat
Created January 14, 2022 07:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MarwanRefaat/9218682890b13e31c237cf16f2202a4d to your computer and use it in GitHub Desktop.
Save MarwanRefaat/9218682890b13e31c237cf16f2202a4d to your computer and use it in GitHub Desktop.
OpenAPI3.yaml
openapi: 3.0.0
info:
version: 1.0.0
title: Simple API
description: A simple API to illustrate OpenAPI concepts
servers:
- url: https://example.io/v1
security:
- BasicAuth: []
paths:
/artists:
get:
description: Returns a list of artists
parameters:
# ----- Added line ------------------------------------------
- $ref: "#/components/parameters/PageLimit"
- $ref: "#/components/parameters/PageOffset"
# ---- /Added line ------------------------------------------
responses:
"200":
description: Successfully returned a list of artists
content:
application/json:
schema:
type: array
items:
# ----- Added line --------------------------------
$ref: "#/components/schemas/Artist"
# ---- /Added line --------------------------------
"400":
# ----- Added line ----------------------------------------
$ref: "#/components/responses/400Error"
# ---- /Added line ----------------------------------------
post:
description: Lets a user post a new artist
requestBody:
required: true
content:
application/json:
schema:
# ----- Added line ------------------------------------
$ref: "#/components/schemas/Artist"
# ---- /Added line ------------------------------------
responses:
"200":
description: Successfully created a new artist
"400":
# ----- Added line ----------------------------------------
$ref: "#/components/responses/400Error"
# ---- /Added line ----------------------------------------
/artists/{username}:
get:
description: Obtain information about an artist from his or her unique username
parameters:
- name: username
in: path
required: true
schema:
type: string
responses:
"200":
description: Successfully returned an artist
content:
application/json:
schema:
type: object
properties:
artist_name:
type: string
artist_genre:
type: string
albums_recorded:
type: integer
"400":
# ----- Added line ----------------------------------------
$ref: "#/components/responses/400Error"
# ---- /Added line ----------------------------------------
components:
securitySchemes:
BasicAuth:
type: http
scheme: basic
schemas:
Artist:
type: object
required:
- username
properties:
artist_name:
type: string
artist_genre:
type: string
albums_recorded:
type: integer
username:
type: string
# ----- Added lines ----------------------------------------
parameters:
PageLimit:
name: limit
in: query
description: Limits the number of items on a page
schema:
type: integer
PageOffset:
name: offset
in: query
description: Specifies the page number of the artists to be displayed
schema:
type: integer
responses:
400Error:
description: Invalid request
content:
application/json:
schema:
type: object
properties:
message:
type: string
# ---- /Added lines ----------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment