-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from surhud004/feat-swagger
Feat swagger documentation
- Loading branch information
Showing
6 changed files
with
468 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"version": "1.0.0", | ||
"title": "Foodish API", | ||
"description": "A Node.js/Express.js REST API to GET a random picture of food dishes." | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "https://foodish-api.com", | ||
"description": "Foodish API server" | ||
} | ||
], | ||
"paths": { | ||
"/api": { | ||
"get": { | ||
"tags": [ | ||
"API" | ||
], | ||
"description": "Get a random food dish image.", | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"application/json": { | ||
"example": { | ||
"image": "https://foodish-api.com/images/burger/burger101.jpg" | ||
} | ||
} | ||
} | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
} | ||
}, | ||
"/api/images/{food}": { | ||
"get": { | ||
"tags": [ | ||
"API" | ||
], | ||
"description": "Get a random food dish image from \"food\" category.", | ||
"parameters": [ | ||
{ | ||
"name": "food", | ||
"in": "path", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
}, | ||
"description": "Required food category." | ||
}, | ||
{ | ||
"name": "keyword", | ||
"description": "Optional filter for food category image. (Beta version: only works for pizza food category. More details: https://github.com/surhud004/Foodish/discussions/14).", | ||
"in": "query", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"application/json": { | ||
"example": { | ||
"image": "https://foodish-api.com/images/burger/burger101.jpg" | ||
} | ||
} | ||
} | ||
}, | ||
"404": { | ||
"description": "Not Found" | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const swaggerAutogen = require('swagger-autogen')({ openapi: '3.0.0' }); | ||
|
||
const doc = { | ||
info: { | ||
version: '1.0.0', | ||
title: 'Foodish API', | ||
description: 'A Node.js/Express.js REST API to GET a random picture of food dishes.' | ||
}, | ||
servers: [ | ||
{ | ||
url: 'https://foodish-api.com', | ||
description: 'Foodish API server' | ||
} | ||
] | ||
}; | ||
|
||
const outputFile = './swagger-api.json'; | ||
const routes = ['../app.js']; | ||
|
||
swaggerAutogen(outputFile, routes, doc); |
Oops, something went wrong.