Skip to content

Instantly share code, notes, and snippets.

@mendhak
Created April 23, 2021 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mendhak/64189150b80a4e52cc88439c5318a17e to your computer and use it in GitHub Desktop.
Save mendhak/64189150b80a4e52cc88439c5318a17e to your computer and use it in GitHub Desktop.
swagger-jsdoc with JSON and YAML jsdoc examples
/**
* @openapi
* "/abc": {
* "get": {
* "description": "Welcome to swagger-jsdoc!",
* "responses": {
* "200": {
* "description": "Returns a mysterious string.",
* "content": {
* "text/xml": {
* "schema": {
* "$ref": "#/components/schemas/MyResponse"
* }
* }
* }
* }
* }
* }
* }
*/
app.get('/abc', (req, res) => {
res.send('Hello World!');
});
/**
* @openapi
* /xyz:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* '200':
* description: Expected response to a valid request
* content:
* application/json:
* schema:
* $ref: "#/components/schemas/MyResponse"
*/
app.get('/xyz', (req, res) => {
res.send('Hello World!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment