Being able to see the class within an EntityModel as a Schema
See original GitHub issueIs your feature request related to a problem? Please describe.
When wrapping a class in a EntityModel, then it would be useful to have that class unwrapped and shown as a Schema from the api-docs. This would be similar to how a class in a CollectionModel gets unwrapped and shown as a Schema from the api-docs.
This is how both EntityModel and CollectionModel are currently represented:
EntityModel
"components":{
"schemas":{
"EntityModel_Example_":{
"type":"object",
"properties":{
...
"_links":{
"$ref":"#/components/schemas/Links"
}
}
}
}
}
CollectionModel
"components":{
"schemas":{
"CollectionModel_Example_":{
"type":"object",
"properties":{
"_embedded":{
"type":"object",
"additionalProperties":{
"type":"array",
"items":{
"$ref":"#/components/schemas/Example"
}
}
},
"_links":{
...
}
}
},
"Example":{
"type":"object",
"properties":{
...
}
}
}
}
Describe the solution you’d like It would be useful to see the class that the EntityModel holds as a Schema.
EntityModel
"components":{
"schemas":{
"EntityModel_Example_":{
"type":"object",
"properties":{
...
"_links":{
"$ref":"#/components/schemas/Links"
},
}
},
"Example":{
"type":"object",
"properties":{
...
}
}
}
}
Describe alternatives you’ve considered None so far
Additional context None
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Schema independent Entity Framework Code First Migrations
My goal is to have schema-independent Code First Migrations (to be able to have one set of migrations for testing and production enviroments)....
Read more >Creating Model Classes with the Entity Framework (C#)
In this tutorial, you learn how to use ASP.NET MVC with the Microsoft Entity Framework. You learn how to use the Entity Wizard...
Read more >How Entity Framework Works?
Entity Framework API (EF6 & EF Core) includes the ability to map domain (entity) classes to the database schema, translate & execute LINQ...
Read more >Spring HATEOAS - Reference Documentation
Also the name changes have been reflected in the classes ... class RepresentationModel class EntityModel class CollectionModel class ...
Read more >Using your own database schema and classes with ASP.NET ...
NET Core Identity and Entity Framework Core ... only requiring the necessary bits for our application to be able to sign in and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @chrisatrotter,
springdoc-open-api removes broken reference definition. If you have noticed, the generated EntityModel only contains the attributes of your class MyAwesomeExampleClass. If this answers your request, the following property will be added to the next release, so you can be able to see MyAwesomeExampleClass schema, even its not referenced directly:
Sorry it took some time, here is a more detailed explanation and answers to your questions:
We are using 1.2.32
Springdoc-openapi-ui and springdoc-openapi-data-rest
Lets take a step back and look at what we are trying to achieve and why:
With the old springfox implementation we would get this when we wrapped a class with EntityModel:
And it also provides a schema for the MyAwesomeExampleClass itself:
Look how awesome it is, standing there proud independent of the EntityModel that is wrapping it, free by itself without “_links”. This is what we are missing in springdoc.
Springdoc gives:
But no schema is given for MyAwesomeExampleClass. And this is a shame, and since it is so awesome of course I want to see it by itself in all its glory. Right now it is mixed with EntityModel, and if those poor front-end people are to look at it, how will they know what fields belong to MyAwesomeExampleClass and what belongs to the EntityModel? Am I supposed to trust front-end to have intimate knowledge of how EntityModel is build up? No, I want to make it easy for them so that they see the schema for my class and knows exactly what to expect from my class.
I want classes that are wrapped in EntityModel to gain its own schema. And following HAL specification (https://apigility.org/documentation/api-primer/halprimer), the schema for the EntityModel puts the class under a “_embedded”.
Springdoc already support this for things wrapped with CollectionModel.
And we also get a schema for EntityModelMyAwesomeExampleClass itself. We simply want springdoc to also give schemas for things wrapped with EntityModel, similarly to how things wrapped with CollectionModel gets their own schema.
• Provide with a minimal sample code.
Example code is in Kotlin Code : ExampleController.zip
Explanation of results in springdoc-ui :
If we have an endpoint that returns MyAwesomeClass wrapped in en EntityModel, springdoc-ui does not show any schema for MyAwesomeClass as depicted in the figure:
Today, if I want a schema for myAwesomeClass, I need to add an endpoint that returns the class without it being wrapped in a ModelEntity. En example of this is :
This gives a schema for my class, as shown in the picture under. But I do not want to have to create an endpoint like that to get the schema automatically generated, but rather that it is generated if a EntityModel wrapps it.