Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alfierichou/galen-back
Using sequelize to generate swagger document.
https://github.com/alfierichou/galen-back
javascript node sequelize swagger
Last synced: 15 days ago
JSON representation
Using sequelize to generate swagger document.
- Host: GitHub
- URL: https://github.com/alfierichou/galen-back
- Owner: AlfieriChou
- License: mit
- Created: 2018-09-22T12:09:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:45:46.000Z (almost 2 years ago)
- Last Synced: 2023-03-02T03:46:16.480Z (almost 2 years ago)
- Topics: javascript, node, sequelize, swagger
- Language: JavaScript
- Homepage:
- Size: 739 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![standard][standard-image]][standard-url]
[![Build Status](https://github.com/AlfieriChou/galen/workflows/ci/badge.svg?branch=master&event=push)](https://github.com/AlfieriChou/galen/actions)
[![Greenkeeper badge](https://badges.greenkeeper.io/AlfieriChou/galen.svg)](https://greenkeeper.io/)
[![license][license-image]][license-url]# How to write swagger document in Sequelize
1. index
```javascript
index: {
path: '/users',
method: 'get',
tags: ['user'],
summary: 'users list',
query: Object.assign(
_.pick(User.rawAttributes, ['nickname']),
{
sort: { type: Sequelize.STRING, comment: 'sort eg: created_at -created_at' }
}
),
output: {
statusCode: {
type: 'array',
result: User.rawAttributes
}
}
}
```
2. create```javascript
create: {
path: '/users',
method: 'post',
tags: ['user'],
summary: 'create user',
requestBody: {
body: _.pick(User.rawAttributes, ['phone', 'password']),
required: ['phone', 'password']
},
output: {
statusCode: {
type: 'object',
result: User.rawAttributes
}
}
}
```3. update
```javascript
update: {
path: '/users/:id',
method: 'put',
tags: ['user'],
summary: 'update user',
params: _.pick(User.rawAttributes, ['id']),
requestBody: {
body: _.pick(User.rawAttributes, ['phone', 'password'])
},
output: {
statusCode: {
type: 'number'
}
}
}
```### routes
* path
* Define the interface baseUrl.* method
* Interface request method.* roles
* api roles* tags
* Interface tag.* summary
* summary is the interface description.* query
* if you query a data source using query.* requestBody
* requestBody includes body and required.
* body: Incoming fields
* required: required field* params
* url parameters, usually is id.* output
* array
```javascript
output: {
200: {
type: 'array',
result: User.rawAttributes
}
}
```* object
```javascript
output: {
200: {
type: 'object',
result: User.rawAttributes
}
}
```* number
```javascript
output: {
200: {
type: 'number'
}
}
```* string
```javascript
output: {
200: {
type: 'string'
}
}
```* html
```javascript
output: {
304: {
type: 'html'
}
}
```[license-image]: https://img.shields.io/badge/License-MIT-yellow.svg
[license-url]: https://opensource.org/licenses/MIT
[standard-image]:
https://cdn.rawgit.com/standard/standard/master/badge.svg
[standard-url]:
https://github.com/standard/standard