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

defineRouteMeta is not working with imported object #2870

Open
de-n3xus opened this issue Nov 11, 2024 · 0 comments
Open

defineRouteMeta is not working with imported object #2870

de-n3xus opened this issue Nov 11, 2024 · 0 comments

Comments

@de-n3xus
Copy link

Environment

Node Version: v20.16.0
Nitro Version: v2.10.4

Reproduction

https://stackblitz.com/edit/github-bwupnk?file=README.md

Route file:

defineRouteMeta({
	openAPI: {
		tags: ['/auth'],
		description: 'Authentication using login/email',
		requestBody: {
			required: true,
			content: {
				'application/json': {
					schema: {
						type: 'object',
						properties: {
							login: {
								type: 'string',
								description: 'Login/email of user',
							},
							password: {
								type: 'string',
								description: 'Password of user',
							},
						},
						required: ['login', 'password'],
					},
				},
			},
		},
		responses: {
			'200 (OK)': {
				description: 'Successful',
				content: {
					'application/json': {
						schema: {
							type: 'object',
							properties: {
								ok: {
									type: 'boolean',
									default: true,
								},
								result: {
									type: 'object',
									properties: {
										accessToken: {
											type: 'string',
											description: 'JWT Access token (1 day)',
										},
										refreshToken: {
											type: 'string',
											description: 'JWT Refresh token (14 days)',
										},
									},
								},
							},
						},
					},
				},
			},
			'4xx, 5xx': ErrorResponse,
		},
	},
})

ErrorResponse file:

import { ReferenceObject, ResponseObject } from 'openapi-typescript'

const response: ResponseObject | ReferenceObject = {
	description: 'Error',
	content: {
		'application/json': {
			schema: {
				type: 'object',
				properties: {
					ok: {
						type: 'boolean',
						default: false,
					},
					error: {
						type: 'object',
						properties: {
							message: {
								type: 'string',
								description: 'Message with error',
							},
						},
					},
				},
			},
		},
	},
}

export default response

Describe the bug

4xx, 5xx response will not be shown in the openapi specification, but 200 will be

Additional context

No response

Logs

No response

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

1 participant