Closed GraysonCAdams closed 8 months ago
@GraysonCAdams yes this cannot be overriden and it is not meant to be. The intended use is:
/components/parameters
then it needs a "hardcoded" definition of where it would be used and what the name is (the in
and name
properties).However seeing your example I believe what you are trying to achieve is the following:
// Register a schema so that it can be reused (the example as well)
const userIdSchema = z.string().openapi('UserId',{
example: '1212121',
});
registry.registerPath({
method: 'get',
path: '/user/',
tags: ['Users],
description: '',
request: {
params: z.object({ userId: userIdSchema }), // use it as a path parameter
query: z.object({ userId: userIdSchema }), // use it as a query parameter
},
security: [{ [bearerAuthName]: [] }],
responses: createApiResponse(UserSchema, 'Success'),
});
Notice how there is no need to manually provide the in/name properties in that case - they are infered from the usage of the request.params and/or request.query.
This code does not work as intended. It looks like if I specify "query" for "in", it just adds it as an additional property, versus overwriting the default.
This error gets thrown:
I reviewed the documentation and cannot find any mention of overwrites versus just adding additional properties. So is this not supported? How would I change the parameter from path-based to query-based if not this way?