Skip to content

defineRouteMeta is not working with imported object #2870

Closed as not planned
Closed as not planned

Description

@de-n3xus

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

Activity

  1. added
    pending triage
    on Nov 11, 2024
  2. danielroe commented on Dec 16, 2024

    @danielroe
    Member

    seems to be a duplicate of #2641

    cc: @pi0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions