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

Introduces "describeModel" interface. #270

Merged
merged 3 commits into from
Nov 24, 2017

Conversation

KaiVolland
Copy link
Member

This introduces a describe-model interface which describes any model as a json-schema.

Makes use of https://github.com/FasterXML/jackson-module-jsonSchema

Does currently not support custom serializers.

*
*/
@Service("modelDescriptionService")
public class ModelDescriptionService<E extends PersistentObject> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<E extends PersistentObject> is not necessary if no instances of PersistentObject are managed by this service.

public class ModelDescriptionService<E extends PersistentObject> {

public JsonSchema getJsonSchema(Class<?> clazz) throws IOException {
ObjectMapper mapper = new ObjectMapper();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a project-specific ObjectMapper that is available as bean (if archetype has been used) and should be used here:

https://github.com/terrestris/shogun2/blob/master/src/shogun2-webapp-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/__artifactId__-servlet.xml#L54

@KaiVolland KaiVolland changed the title [WIP] Introduces "describeModel" interface. Introduces "describeModel" interface. Nov 23, 2017
Copy link
Member

@marcjansen marcjansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, one remark which you may want to take. Please merge at will.

It would be very nice if you could change the archetype to include a matching bean describeModelSearchPackages.


JsonSchema json = modelDescriptionService.getJsonSchema(foundClass);

JsonSchema json = modelDescriptionService.getJsonSchema(className);
return ResultSet.success(json);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to return a ResultSet.error() if the json is null. you decide.

@KaiVolland KaiVolland merged commit 0b3c383 into terrestris:master Nov 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants