-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#135.6 users API에 swagger 적용 #439
Conversation
Main branch update from Dev branch
Main branch update from Dev branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 수고하셨습니다 :)
responses: { | ||
200: { | ||
content: { | ||
"text/html": { | ||
example: | ||
"Users/agreeOnTermsOfService : agree on Terms of Service successful", | ||
}, | ||
}, | ||
}, | ||
400: { | ||
content: { | ||
"text/html": { | ||
example: "Users/agreeOnTermsOfService : already agreed", | ||
}, | ||
}, | ||
}, | ||
500: { | ||
content: { | ||
"text/html": { | ||
example: "Users/agreeOnTermsOfService : internal server error", | ||
}, | ||
}, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 방법도 있네염..
왜 스웨거 코드는 볼 때마다 맘에 안든는지... 😢😢
module.exports = function (app) {
app.get('/users/:id', (req, res) => {
// #swagger.tags = ['User']
// #swagger.description = 'Endpoint para obter um usuário.'
// #swagger.parameters['id'] = { description: 'ID do usuário.' }
/* #swagger.parameters['filtro'] = {
in: 'query',
description: 'Um filtro qualquer.',
type: 'string'
} */
const filtro = req.query.filtro
if(false)
return res.status(404).send(false)
/* #swagger.responses[200] = {
schema: { $ref: "#/definitions/User" },
description: 'Usuário encontrado.'
} */
return res.status(200).send(data)
})
app.post('/users', (req, res) => {
/* #swagger.tags = ['User']
#swagger.description = 'Endpoint para adicionar um usuário.' */
/* #swagger.parameters['newUser'] = {
in: 'body',
description: 'Informações do usuário.',
required: true,
schema: { $ref: "#/definitions/AddUser" }
} */
const newUser = req.body
if (true) {
// #swagger.responses[201] = { description: 'Usuário registrado com sucesso!' }
return res.status(201).send(data)
}
return res.status(500) // #swagger.responses[500]
})
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드에 주석으로 주렁주렁 달기 vs 파일 하나에 왕창 몰아넣기 이 문제네요 흑흑
개발자 지인이 말하기를 swagger는 문서화가 아니라 개발이라고 하는데 맞는 것 같습니다...
나중에 저런 반복되는 부분은 code랑 text만 받아서 생성되게 자동화 하면 훨씬 깔끔해질 것 같은데 한 번 해볼게요~!
Summary
It closes #135
Extra info
users.js
를 swagger을 사용하여 문서화합니다.send message를 통일하는 과정에서
/services
코드도 일부 변경하였습니다.Images or Screenshots
Further Work