-
-
Notifications
You must be signed in to change notification settings - Fork 286
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
[FEAT] OAS3 — allow to configure serialization attributes for query parameters #2301
Comments
Hello @denis-maiorov-brightsec In fact you can configure any global settings through the {
"swagger": [
{
"path": "/doc",
"spec": {
"parameterSerialization": {
"query": {
// key in OpenSpecTypes
"object": {
"style": "deepObject",
"explode": true
}
}
}
}
}
]
} See you |
Making PR to add typing is also possible: |
Thanks for having a look! The problem is that there's no such global option in Swagger 😢. Those |
Ok I see. Yes, Ts.ED support deep query parameters and the style: deepObject is automatically enabled is you use a model on query. See more here: |
@Romakita ah, I see. The problem then is that It's not working when @Generics('T')
export class QueryParamBetweenFilter<T> {
@Description('Greater than constraint')
@Property('T')
public gt?: T;
@Description('Greater than or equal constraint')
@Property('T')
public gte?: T;
@Description('Less than constraint')
@Property('T')
public lt?: T;
@Description('Less than or equal constraint')
@Property('T')
public lte?: T;
}
export class Filters {
@GenericOf(number().integer())
public param?: QueryParamBetweenFilter<number>;
}
@Controller({path: '/test'})
class TestDeepObjectCtrl {
@Get('/works')
public get(@QueryParams("param") @GenericOf(number().integer()) q: QueryParamBetweenFilter<number>) {
}
@Get('/doesNotWork')
public get(@QueryParams() filters: Filters) {
}
} |
it's probably a missing usecase in |
@Romakita seems like I should close this issue and open a bug issue then? |
Yes if you have a time. Keep this issue open also. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Information
Is your feature request related to a problem? Please describe.
Swagger UI allows to "try" endpoints. It then composes url based on serialization rules. At the moment there is no way to configure these rules. They do not align with
platform-express
deserialization well. In most cases it works but query object parameters requiredeepObject
style.Describe the solution you'd like
As deserialization is usually depends on platform and/or configured globally, the solution is to set serialization attributes(
style
,explode
) for query parameters on global level.Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Acceptance criteria
The text was updated successfully, but these errors were encountered: