Skip to content

Expose @Id fields for entity with spring-data-rest/springdoc-openapi-data-rest #1146

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

Closed
janderssonse opened this issue Apr 25, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@janderssonse
Copy link

janderssonse commented Apr 25, 2021

Is your feature request related to a problem? Please describe.

Background:

We have an 'REST api based on mostly spring-data-rest - An Entity field @id in configured to be exposed with a configuration on the Spring RepositoryRestConfiguration - exposeIdsFor(ENTITY.class). All well there but,,,

The same @id field is not visible in the documentation generated for the same Entity model with springdoc-openapi-data, since v1.5.6. I have tried setting hidden=false directly on it using the @Schema-annotation, like this.

@Schema(
description = "The Internal Job Identity", example = "fb2baa17-8972-451b-bb1e-1bc773283476",
accessMode = Schema.AccessMode.READ_ONLY, hidden=false, defaultValue = "A random UUID"
)
@id val id: UUID = UUID.randomUUID(),

  • What is the actual result using OpenAPI Description (yml or json)?

The field with @id is missing, even though we set hidden=false on it

Describe the solution you'd like

openapi-spring-rest-data should respect the RepositoryRestConfiguration - exposeIdsFor(ENTITY.class) configuration.

OR

allow an configuration like in Spring-rest-data to expose @ids, for example, springdocRespositoryRestConfiguration - exposeIdsFor(

OR

respect that if the hidden=false is set on on an @id field and expose it.

Describe alternatives you've considered

  • Searched in the docs, looked at a few examples, tried setting hidden=false on the @Schema for the @id field.

The @id field was exposed automatically up until version 1.5.5, but after 1.5.6 of the libs it is gone.

Additional context
The @id field is not visible ...

Skärmbild från 2021-04-25 11-23-51

Skärmbild från 2021-04-25 11-23-05

Note: I'm using the following dependencies:

//openapi generation
implementation("org.springdoc:springdoc-openapi-ui:1.5.7")
implementation("org.springdoc:springdoc-openapi-kotlin:1.5.7")
implementation("org.springdoc:springdoc-openapi-data-rest:1.5.7")
implementation("org.springdoc:springdoc-openapi-hateoas:1.5.7")

@janderssonse
Copy link
Author

I downgraded to version 1.5.5 as a test, and then the field was exposed as expected !! hmm.
Skärmbild från 2021-04-25 11-45-24

@janderssonse
Copy link
Author

But with 1.5.6 the id is gone.

I'll solve this just staying on 1.5.5 for the libs until further.

@bnasslahsen
Copy link
Collaborator

@janderssonse,

exposeIdsFor, should be considered for the next release.
You can use the latest snapshot to validate it.

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants