Skip to content

Spring Data REST: force openapi schema export #2295

Closed
@fkjaekel

Description

@fkjaekel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions