You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that the required field is broken for query parameters as using it in all variants has no impact on generated code. Pameter type can be anything so I've made it for boolean.
The problem is that no matter if I make my "duck" parameter mandatory (required: true) or optional (required: false or leave it out), the generated code is exactly the same:
I might be wrong here but I suppose it's a bug as I'd expect the generated handler to return some sort of user error code (400? 404?) if the user didn't provide parameter for the required: true field.
The generated code is IMO fine for optional parameters now, but perhaps mandatory fields could be handled like that:
response.send(Pistache::Http::Code::Bad_Request, R"(Field "duck" wasn't provided)"); // "duck" was the first unsatisfied
or something more generic when there are multiple required parameters.
The text was updated successfully, but these errors were encountered:
👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
kuzkry
changed the title
[BUG][C++] required is meaningless in query parameters
[BUG][C++][Pistache] required field is meaningless in query parameters
Apr 9, 2020
Description
It seems that the
required
field is broken for query parameters as using it in all variants has no impact on generated code. Pameter type can be anything so I've made it for boolean.openapi-generator version
I use OpenAPI Generator 4.3.0. I've got no idea if this is regression.
OpenAPI declaration file content or url
The problem is that no matter if I make my "duck" parameter mandatory (
required: true
) or optional (required: false
or leave it out), the generated code is exactly the same:The only difference is in the generated comment in .h file which is:
required: true
/// <param name="duck">property value</param>
required: false
or "nothing"/// <param name="duck">property value (optional, default to false)</param>
Command line used for generation
java -jar openapi-generator-cli.jar generate -i issue.yaml -g cpp-pistache-server -o generated
Steps to reproduce
N/A
Related issues/PRs
I haven't found one.
Suggest a fix/enhancement
I might be wrong here but I suppose it's a bug as I'd expect the generated handler to return some sort of user error code (400? 404?) if the user didn't provide parameter for the
required: true
field.The generated code is IMO fine for optional parameters now, but perhaps mandatory fields could be handled like that:
or something more generic when there are multiple required parameters.
The text was updated successfully, but these errors were encountered: