-
Notifications
You must be signed in to change notification settings - Fork 474
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
Prop isArray is incorrectly added when using @ApiQuery decorator with enum values #1221
Comments
When fixing this locally for related #1179 I used this yarn patch: diff --git a/dist/decorators/api-query.decorator.js b/dist/decorators/api-query.decorator.js
index 73ce9283619b232c29f0714aa782066d1dc913fd..3ac8739b00b62bfe227f7ce205de19858c327e40 100644
--- a/dist/decorators/api-query.decorator.js
+++ b/dist/decorators/api-query.decorator.js
@@ -11,14 +11,18 @@ const defaultQueryOptions = {
function ApiQuery(options) {
const apiQueryMetadata = options;
const [type, isArray] = helpers_1.getTypeIsArrayTuple(apiQueryMetadata.type, apiQueryMetadata.isArray);
- const param = Object.assign(Object.assign({ name: lodash_1.isNil(options.name) ? defaultQueryOptions.name : options.name, in: 'query' }, lodash_1.omit(options, 'enum')), { type,
- isArray });
+ const param = Object.assign(Object.assign({ name: lodash_1.isNil(options.name) ? defaultQueryOptions.name : options.name, in: 'query' }, lodash_1.omit(options, 'enum')), { type });
if (enum_utils_1.isEnumArray(options)) {
enum_utils_1.addEnumArraySchema(param, options);
}
else if (enum_utils_1.isEnumDefined(options)) {
enum_utils_1.addEnumSchema(param, options);
}
+
+ if(isArray) {
+ param.isArray = isArray;
+ }
+
return helpers_1.createParamDecorator(param, defaultQueryOptions);
}
exports.ApiQuery = ApiQuery; |
Would you like to create a PR for this issue? |
3 tasks
Let's track this here #1223 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm submitting a...
Current behavior
Applying an
APIQuery
decorator to a controller method which uses an enum:produces json:
When converted to yaml and pasted into the Swagger Editor produces validation errors as the
isArray
property should not exist.Manually removing the isArray property in the Swagger Editor solves the issue.
Expected behavior
The
isArray
property should not be present when a query parameter is an enum value.Minimal reproduction of the problem with instructions
Minimal Reproduction Repo
Instructions
What is the motivation / use case for changing the behavior?
To create valid OpenAPI documents.
Environment
The text was updated successfully, but these errors were encountered: