Skip to content

Instantly share code, notes, and snippets.

@mathis-m
Created October 3, 2021 19:17
Show Gist options
  • Save mathis-m/2f6adb2922a15ac037d3610ff145e556 to your computer and use it in GitHub Desktop.
Save mathis-m/2f6adb2922a15ac037d3610ff145e556 to your computer and use it in GitHub Desktop.
openapi: "3.0.2"
info:
title: Sample API
description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
version: 0.1.9
servers:
- url: "xxxxx"
paths:
/hello/user:
post:
operationId: createUser
summary: create a user
description: create new user
requestBody:
description: new user
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User'
responses:
'200':
description: OK
content:
application/json:
schema:
type: string
# -----------------------------------------------------
# Links
# -----------------------------------------------------
links:
GetUserByUserId: # <---- arbitrary name for the link
operationId: getUser
# or
# operationRef: '#/paths/~1users~1{userId}/get'
parameters:
uid: '$request.body#/uid'
description: >
The `uid` value returned in the response can be used as
the `uid` parameter in `GET /hello/user`.
# -----------------------------------------------------
get:
operationId: getUser
summary: Return a user
description: Optional extended description in CommonMark or HTML.
parameters:
- in: query
name: uid
schema:
type: integer
responses:
'200': # status code
description: return a user
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: Object
required:
- uid
properties:
name:
type: string
uid:
type: integer
example:
uid: 1
name: 'juno'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment