-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem?
When creating the endpoint with status code different than 200, I should always explicitly define needed status code in the controller (e.g. res.status(201)).
What feature would you like to see?
It would be better to automatically use defined status codes from API spec
Example:
openapi: '3.0.3'
info:
title: Node App API
version: '0.0.1'
paths:
/api/v1/someEndpoint
get:
operationId: someEndpoint
summary: Do something
responses:
'201':
description: Done
content:
application/json:
schema:
$ref: '#/components/schemas/SomeSchema'Before:
export const someController = ctrl.createRestController({
someEndpoint: async (_req, ctx, res) => {
await someService.doSomething(ctx)
res.status(201) // Otherwise it will return `200`
return { foo: 'bar' }
}After:
export const someController = ctrl.createRestController({
someEndpoint: async (_req, ctx, res) => {
await someService.doSomething(ctx)
return { foo: 'bar' } // Automatically return `201`
}What alternatives have you considered?
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request