Skip to content

Add JSON schema support #444

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

Open
sdeleuze opened this issue Apr 12, 2016 · 5 comments
Open

Add JSON schema support #444

sdeleuze opened this issue Apr 12, 2016 · 5 comments
Assignees
Labels
in: mediatypes Media type related functionality

Comments

@sdeleuze
Copy link

It would be super useful for Spring Hateoas to support additional documentation metadata like being able to describe JSON data with JSON schema.

See also #16 for related discussion.

@odrotbohm
Copy link
Member

What would that support look like? Spring HATEOAS doesn't know anything about the structure of the application level content. All it currently cares about is hypermedia controls and how to create them. Note that there is JSON Schema support in Spring Data REST, where I think it makes a lot of sense, as — through the Spring Data PersistentEntity API — that library has information about the parts of the representation that resemble domain types, which basically means that there's something to actually create a schema for.

@odrotbohm odrotbohm self-assigned this Apr 12, 2016
@sdeleuze
Copy link
Author

My use case is really about allowing JSON schema support in any kind of RESTful Spring Boot + applications using @RestController, not only Spring Data REST based ones.

I think such feature would help to provide an alternative with Spring HATEOAS + Spring REST Docs (cc @wilkinsona) to OpenAPI (very Swagger oriented, and not HATEOAS compliant at all) or RAML that are documenting a wide range of informations (Spring REST docs provides human readable specs but not machine readable ones), and would be complementary to this PR about providing title and type properties.

Such additional metadata could be used for various purpose:

  • Automated testing of RESTful APIs
  • Developer documentation for free
  • Expose more information for libraries like Orbit.js

As mentioned in this blog post or implemented by Spring REST Docs, it could maybe use by default the field names, types and Bean Validation annotations, while providing some extension points to add/customize contraints.

Any thoughts?

@gregturn
Copy link
Contributor

The only avenue I see to implement something would be providing an API to build a JSON Schema compliant document. But it would be to the library user to actually use it.

I don't know how easy or hard it is to build that given Spring HATEOAS isn't setup for building metadata documents.

@sdeleuze
Copy link
Author

Using https://github.com/FasterXML/jackson-module-jsonSchema would have been a possible solution I guess.

But Indeed, that's maybe outside of Spring HATEOAS scope. Maybe supporting JSON schema would be better at Spring REST docs level (see this issue) or at RAML level for those who seeks machine readable specs ...

See this discussion about HATEOAS support in RAML forums.

Feel free to close this issue if you think this is outside of Spring HATEOAS scope.

@gregturn
Copy link
Contributor

gregturn commented Jun 5, 2020

@odrotbohm can we simply move the JSON Schema builders from Spring Data REST to Spring HATEOAS?

SDR can continue to use them. Spring HATEOAS can now offer them to anyone else that wants to manually assemble such a docu.

@gregturn gregturn added the in: mediatypes Media type related functionality label Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mediatypes Media type related functionality
Projects
None yet
Development

No branches or pull requests

3 participants