-
-
Notifications
You must be signed in to change notification settings - Fork 524
Hateoas fields names mismatch #401
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
Comments
@jlefebvre-vsct, |
Hi @bnasslahsen sorry, I don't know the spec well but the generated openapi doesn't match what is actually produced and I don't manage to get them match (any workaround ?). I have prepared the following demo to illustrate and facilitate further investigation : Useful demo endpoints :
Notable differences :
|
I don't know springdoc nor swagger at all but I looked at them to figure out how to fix these problems.
|
"content" of PagedModel was wrong because I was using ResponseEntity<PagedModel<RepresentationModel<EntityModel>> instead of ResponseEntity<PagedModel<EntityModel> |
everything matches when NOT using HAL format 👍 @Configuration
public class SpringRestConfiguration implements RepositoryRestConfigurer {
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
config.setDefaultMediaType(MediaType.APPLICATION_JSON);
config.useHalAsDefaultJsonMediaType(false);
}
} and spring.hateoas.use-hal-as-default-json-media-type: false |
Hi @jlefebvre-vsct, Thank you for providing all this relevant information. BTW, for your sample you just need to declare springdoc-openapi-ui and springdoc-openapi-data-rest:
|
@bnasslahsen Is there any doc about "better support for HAL fields naming" ? |
Hi @ch4mpy, By default, you just need to add springdoc-openapi-data-rest: You can have a look at some code examples in the tests:
|
@bnasslahsen thank you for your answer. I had missed the parapgraph about Pageable support (I don't know how as I applied the security one...) The json schema now seems ok. Unfortunately, openapitools (4.3.0) then fails to process it:
but I couldn't yet figure out if it's related to a bad schema or bogous tool... |
@bnasslahsen I think the issue in in springdoc: I opened an issue for that: #609 |
The naming of the fields does not match the HAL specification draft (link) : the generated documentation (based on EntityModel) and the actual JSON representations are different, e.g. "links" instead of "_links" and using default name "content" instead of the specified one by using @org.springframework.hateoas.server.core.Relation(collectionRelation = "components") on the object class.
I am using Spring-boot 2.2.x and Springdoc-openapi 1.2.30.
The expected behavior is that the generated OpenAPI3 contract matches the effective produced data structure (the purpose of generating from sources 😄).
The text was updated successfully, but these errors were encountered: