question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Define default values for required property per parameter type

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
neon-devcommented, Jun 3, 2019

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.

1reaction
EricWittmanncommented, Jun 3, 2019

We discussed this issue in today’s hangout. Here is what we have (tentatively?) decided to do:

  • No changes will be made to the text of the Microprofile OpenAPI specification
  • The TCK will be updated to ensure that Query parameters are not set as required by default

To be clear, the TCK will not assert that the required property for query parameters is false. Instead, it will assert that the required 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found