-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
The generator adds $id
and $ref
to the spec which are not allowed there. There is a similar issue. I hoped 1.3.0
would fix this, but the issue is still present no matter what I use for reference t.Ref()
or Elysia.Ref()
the code:
import swagger from '@elysiajs/swagger' import { Elysia, t } from 'elysia' export const User = new Elysia() .model('user', t.Object({ id: t.String(), firstName: t.String(), lastName: t.String(), })) export const GetUserSchema = { response: { 200: { ...User.Ref('user'), description: 'ok' }, 404: t.String({ description: 'User not found' }), }, } new Elysia() .use(swagger()) .use(User) .get('user/', () => { return { id: '1', firstName: 'John', lastName: 'Doe' } }, { ...GetUserSchema, parse: ['application/json'] }) .listen(3001)
The generated invalid schema:
{ "openapi": "3.0.3", "info": { "title": "Elysia Documentation", "description": "Development documentation", "version": "0.0.0" }, "paths": { "/user/": { "get": { "responses": { "200": { "$ref": "user", // this should not be here. When I try to generate a client, the client ignores the response types "description": "ok", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/user", "description": "ok" } } } }, "404": { "description": "User not found", "content": { "application/json": { "schema": { "description": "User not found", "type": "string" } } } } }, "operationId": "getUser" } } }, "components": { "schemas": { "user": { "type": "object", "properties": { "id": { "type": "string" }, "firstName": { "type": "string" }, "lastName": { "type": "string" } }, "required": [ "id", "firstName", "lastName" ], "$id": "#/components/schemas/user" // this is couse error. It should not be here } } } }
You could use swagger validator to check if there is no errors
Victorcassiano, mattp04, mikkelam, meness and Serdnad
Metadata
Metadata
Assignees
Labels
No labels