Different semantic of produces and consumes on client and controller side #79
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
renovate
renovate-manager
cargo
renovate-manager
dockerfile
renovate-manager
git-submodules
renovate-manager
gomod
renovate-manager
kustomize
renovate-manager
kustomize
renovate-manager
maven
renovate-manager
maven
renovate-manager
npm
renovate-manager
pip_requirements
renovate-manager
regex
renovate-manager
renovate-config-presets
renovate-manager
woodpecker
renovate-type
bump
renovate-type
digest
renovate-type
lockFileMaintenance
renovate-type
major
renovate-type
minor
renovate-type
patch
renovate-type
pin
renovate-type
pinDigest
renovate-type
replacement
renovate-type
rollback
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Reference
kokuwaio/micronaut-openapi-codegen#79
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As stated in the documentation at https://docs.micronaut.io/latest/guide/index.html#clientAnnotation @Produces (as well as @Consumes) has different semantics on client and server side. From the docs:
Therefore, the mapping of:
would be expected to result in:
But it is currently mapped to:
The current mapping plus the default functionality of the Micronaut HTTP client leads to a client sending the get request with an automatically created Accept: application/json header. If the server is validating the Accept Header, it answers with 406, because it can only produce ld+json.
The mapper must respect the different meanings of @Produces (and @Consumes) on client and server side.
I cannot reproduce that problem. When I use it exactly the same way(or maybe I overlooked a difference), the client produces the expected header (and Consumes annotation).
This spec:
produces the client code:
The request looks as following:
Maybe you can spot the difference, the code is here: https://github.com/wistefan/contract-service
Btw. are we working on the same stuff?:) Your problems look very familiar.
Hi Stefan,
have a look at this code snippet generated from your example:
If the EntitiesAPI interface is implemented by a Controller, then the annotations are correct.
But the HTTP Client should look like this:
It should use @Consumes. Which it does not if I generate the code from your example.
Can you check the Accept Header that your EntitiesApiClient is sending to the Server when doing a queryEntities? I assume it will not contain application/ld+json.
Your right. This looks like a problem with the GET requests. It worked, because I tried it with a POST.
Will be fixed with version 3.0.0
Fixed with 3.x