Define default values for required property per parameter type
See original GitHub issueI couldn’t find much info about query parameter handling in the spec. This example already suggests, it could be an optional parameter and I would agree: https://github.com/eclipse/microprofile-open-api/blob/master/spec/src/main/asciidoc/microprofile-openapi-spec.adoc#requestbody
However some implementors set them required by default, just like @PathParam
or @FormParam
(where it’s fine).
As discussed in https://github.com/smallrye/smallrye-open-api/issues/110 one could consider defining requirements in the spec for each possible parameter type.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Set default value for an Object parameter in TypeScript
To set default value for an object parameter, type the object as having one or more optional properties. Set default value for each...
Read more >Set a default parameter value for a JavaScript function
Default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed. Syntax: function [name]([param1[ = ......
Read more >about Parameters Default Values - PowerShell | Microsoft Learn
The $PSDefaultParameterValues preference variable lets you specify custom default values for any cmdlet or advanced function.
Read more >Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >Object orientation - The Apache Groovy programming language
Default arguments make parameters optional. If the argument is not supplied, the method assumes a default value. def foo(String ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Glancing over the source code on GitHub it looks like it already handles that correctly: https://github.com/smallrye/smallrye-open-api/blob/e29bdabc89aae81e00be32cdb4dd5a34f551f6c2/implementation/src/main/java/io/smallrye/openapi/runtime/scanner/OpenApiAnnotationScanner.java#L555 I’m currently on vacation so I don’t have a project at hand were I experienced this. I’ll create an issue in a week or two when I can verify this behavior.
We discussed this issue in today’s hangout. Here is what we have (tentatively?) decided to do:
To be clear, the TCK will not assert that the
required
property for query parameters is false. Instead, it will assert that therequired
property for a query parameter is either not present or present and false.We will also update the TCK to make sure that query parameters can be marked as required by using a separate OpenAPI annotation to explicitly set that property value.
Also note - these same rules will apply to cookie and header parameters as well.