fix(swagger-types-mapper): place multipleOf inside parameter schema#3882
Merged
kamilmysliwiec merged 1 commit intoApr 28, 2026
Conversation
When a parameter (e.g. @apiquery, @ApiParam) is declared with a `multipleOf` constraint without an explicit `schema` host, the value was kept at the parameter top level instead of being moved into `parameter.schema`. This produced an invalid OpenAPI parameter object because numeric validation keywords like `multipleOf` belong inside the parameter's schema. Add `multipleOf` to the list of recognised schema option keys so it is correctly placed under `schema` for both scalar and array parameters, mirroring the existing handling of `minimum`, `maximum`, `exclusiveMinimum`, etc.
Member
|
lgtm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
When a parameter (e.g.
@ApiQuery,@ApiParam) is declared with amultipleOfconstraint without an explicitschemahost, the value is left at the parameter top level instead of being moved intoparameter.schema. The resulting OpenAPI parameter object is invalid because OAS numeric validation keywords likemultipleOfbelong inside the parameter's schema, alongsideminimum/maximum/etc.Example input:
Current output (truncated):
{ "name": "count", "in": "query", "required": true, "multipleOf": 5, // <-- wrong location "schema": { "type": "number" } }The same problem exists for array-typed parameters —
multipleOfis dropped entirely from the generated schema.SwaggerTypesMapper#getSchemaOptionsKeysenumerates the SchemaObject keys that should be promoted from a parameter's top-level options into itsschemablock.multipleOfis missing from that list even though it is declared onSchemaObjectand is generated by the plugin for DTOs (e.g. via@IsDivisibleBy).What is the new behavior?
multipleOfis now included in the schema options key list, so it is placed underparameter.schemafor both scalar and array parameters, matching howminimum,maximum,exclusiveMinimum, etc. are already handled.{ "name": "count", "in": "query", "required": true, "schema": { "type": "number", "multipleOf": 5 } }Additional context (optional)
Added a small
SwaggerTypesMapperunit test covering both the scalar and the array-parameter codepaths. The existingswagger-explorersuite (53 tests) continues to pass.