Skip to content
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

Spring Data REST: force openapi schema export #2295

Closed
fkjaekel opened this issue Jul 5, 2023 · 4 comments
Closed

Spring Data REST: force openapi schema export #2295

fkjaekel opened this issue Jul 5, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@fkjaekel
Copy link

fkjaekel commented Jul 5, 2023

When working with SDR, I need that the associated resources are expanded in the returned JSON. I have achieved this by adding @RestResource(exported = false) to the associated resource. For example:

@NotNull
@RestResource(exported = false)
@ManyToOne(fetch = FetchType.EAGER)
private Client client;

So far so good, as I can read and write to the association without extra requests. The problem is that I use openapi-generator to create feign clients of the API, and in this case the Client entity is not exported in the openapi schema, so I need this workaround to get it exported:

public Client getClientInline()
{
    return client;
}

I'd like to know if is there any way to get rid of this workaround. I made a test with an excerpt projection, but the schema also doesn't get exported. Adding @SchemaProperty also doesn't helps.

This is the current schema output:

"EntityModelIntegrationConfig": {
"required": [
"client",
"cron",
"enabled",
"template"
],
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"readOnly": true
},
"cron": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"templateInline": {
"$ref": "#/components/schemas/Template"
},
"clientInline": {
"$ref": "#/components/schemas/Client"
},
"links": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Link"
}
}
}
}

The expected behavior is to have client and template to be treated as properties, so I can remove the additional "inline" getters.

Sorry to post this here, but I didn't figured this out by looking at documentation / source code / stackoverflow

Thanks in advance

@bnasslahsen
Copy link
Contributor

If you are reporting a bug, please help to speed up problem diagnosis by providing as much information as possible:

  • You need to describe your context (the title of an issue is not enough)
  • What version of spring-boot you are using?
  • What modules and versions of springdoc-openapi are you using?
  • What are the actual and the expected result using OpenAPI Description (yml or json)?
  • Provide a Minimal, Reproducible Example - with HelloController that reproduces the problem

This ticket will be closed and can be reopened if the relevant information are provided.

@bnasslahsen bnasslahsen added the incomplete incomplete description: Make sure you Provide a Minimal, Reproducible Example - with HelloController label Jul 16, 2023
clementdenis added a commit to clementdenis/springdoc-openapi that referenced this issue Feb 15, 2024
clementdenis added a commit to clementdenis/springdoc-openapi that referenced this issue Feb 15, 2024
clementdenis added a commit to clementdenis/springdoc-openapi that referenced this issue Feb 15, 2024
clementdenis added a commit to clementdenis/springdoc-openapi that referenced this issue Feb 15, 2024
@clementdenis
Copy link

@bnasslahsen I pushed #2511 to fix this.

@bnasslahsen
Copy link
Contributor

Thanks @clementdenis,
I will take care of it very soon!

@bnasslahsen bnasslahsen reopened this Feb 15, 2024
@bnasslahsen bnasslahsen added bug Something isn't working and removed incomplete incomplete description: Make sure you Provide a Minimal, Reproducible Example - with HelloController labels Feb 15, 2024
@bnasslahsen
Copy link
Contributor

Fixed by #2501

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants