Skip to content
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

Add support for "default" response #120

Open
sidec15 opened this issue May 19, 2021 · 1 comment
Open

Add support for "default" response #120

sidec15 opened this issue May 19, 2021 · 1 comment

Comments

@sidec15
Copy link

sidec15 commented May 19, 2021

Currently is not possible to define a default response block because the "response" decorator accepts an argument with type IResponses:

export interface IResponses {
  [name: number]: any;
}

So is not possible to assign a string as key.

The desiderata woud be to allow the following:

@responses({
	200: { description: "success",
	"default": {description: "default error"}
})

The resulting json must have the following structure:

responses:
	200:
	  description: Success
	  schema:
		$ref: '#/definitions/User'
	# Definition of all error statuses
	default:
	  description: Unexpected error
	  schema:
		$ref: '#/definitions/Error'
@sidec15
Copy link
Author

sidec15 commented May 19, 2021

A possible workaround could be:

const DEFAULT_ERROR_KEY: number = "default" as unknown as number

@responses({
	200: { description: "success",
	[DEFAULT_ERROR_KEY]: {description: "default error"}
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants