You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This enables you to implicitly transform an ID to an entity from the DB, like:
@Get('/')
@ResponseSchema(TaskRecord,{isArray: true})
@OpenAPI({summary: 'Lists all records of the user.'})publicasyncgetAll(@EntityFromQuery('user')user: User){returnawaitthis.records.getRecordsOf(user);}
But the problem is that the parameter passed is an integer in fact, but the OpenAPI spec generator thinks that the parameter is an entity/object, to circumvent this I've added the parameter to the OpenAPI decorator, like:
But (I suppose that) because of the merging logic of the decorators (Mentioned in the readme - "Multiple @OpenAPI decorators"), the integer type and the entity $ref gets merged:
Instead of passing OpenAPI an object try passing a function which performs the merge manually. From the docs:
Alternatively you can call @openapi with a function of type (source: OperationObject, route: IRoute) => OperationObject, i.e. a function receiving the existing spec as well as the target route, spitting out an updated spec. This function parameter can be used to implement for example your own merging logic or custom decorators.
You might first want to try passing in a function that just logs its parameters to get a sense of what's going on.
I'm using routing controllers openapi, along with typeorm and routing controllers typeorm extension.
This enables you to implicitly transform an ID to an entity from the DB, like:
But the problem is that the parameter passed is an integer in fact, but the OpenAPI spec generator thinks that the parameter is an entity/object, to circumvent this I've added the parameter to the OpenAPI decorator, like:
But (I suppose that) because of the merging logic of the decorators (Mentioned in the readme - "Multiple @OpenAPI decorators"), the integer type and the entity $ref gets merged:
Which is wrong, and swagger UI displays it as "User" type:
Can we avoid that in some way? (IE: Specify that the field must not be merged)
The text was updated successfully, but these errors were encountered: