Skip to content

rnemykin/json-schema-spring-boot-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Json schema spring boot starter

Auto configuration for json-schema-validator

How to use

  1. Dependency
<dependency>
    <groupId>ru.rnemykin.spring.boot</groupId>
    <artifactId>json-schema-spring-boot-starter</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>
  1. Use default configuration or define your own
@Bean
public Library library(AbstractKeywordProcessor processor, ApplicationContext ctx) {
    LibraryBuilder builder = DraftV4Library.get().thaw();
    builder.addKeyword(
            Keyword.newBuilder(processor.keyword())
                    .withSyntaxChecker(...)
                    .withDigester(...)
                    .withValidatorFactory(new SpringAwareKeywordValidatorFactory(...)
                    .freeze()
    );
    return builder.freeze();
}    
  1. Write custom keywordValidators
@ToString
@Component
public class EnumDbValueKeywordProcessor extends AbstractKeywordProcessor {
   .....
}
  1. Do validation (see example)
@Autowired
private JsonSchemaFactory jsonSchemaFactory;
//...
ProcessingReport report = jsonSchemaFactory.getValidator().validate(schema, entity);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages