{"id":15013051,"url":"https://github.com/janloebel/json-schema-validation-starter","last_synced_at":"2025-07-01T03:04:58.567Z","repository":{"id":49269583,"uuid":"229444701","full_name":"JanLoebel/json-schema-validation-starter","owner":"JanLoebel","description":"Spring Boot 2 Starter for Json Schema Validation","archived":false,"fork":false,"pushed_at":"2024-04-22T08:29:46.000Z","size":55,"stargazers_count":9,"open_issues_count":3,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-01T03:03:33.893Z","etag":null,"topics":["boot","json","jsonschema","schema","spring","springboot","starter","validation"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JanLoebel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://paypal.me/janloebel"}},"created_at":"2019-12-21T15:13:34.000Z","updated_at":"2024-08-31T17:51:05.000Z","dependencies_parsed_at":"2024-04-22T09:54:06.456Z","dependency_job_id":null,"html_url":"https://github.com/JanLoebel/json-schema-validation-starter","commit_stats":{"total_commits":30,"total_committers":7,"mean_commits":4.285714285714286,"dds":0.6,"last_synced_commit":"c73b1ebf8d7ace6196a3988dd97ece2b7bdcddee"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/JanLoebel/json-schema-validation-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanLoebel%2Fjson-schema-validation-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanLoebel%2Fjson-schema-validation-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanLoebel%2Fjson-schema-validation-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanLoebel%2Fjson-schema-validation-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JanLoebel","download_url":"https://codeload.github.com/JanLoebel/json-schema-validation-starter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanLoebel%2Fjson-schema-validation-starter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262887183,"owners_count":23379767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boot","json","jsonschema","schema","spring","springboot","starter","validation"],"created_at":"2024-09-24T19:43:39.889Z","updated_at":"2025-07-01T03:04:58.527Z","avatar_url":"https://github.com/JanLoebel.png","language":"Java","funding_links":["https://paypal.me/janloebel","https://www.buymeacoffee.com/JanLoebel"],"categories":[],"sub_categories":[],"readme":"# Json-Schema-Validation-Starter\n\nThis provides a Spring-Boot-Starter to include JsonSchemaValidation with the help of the [https://github.com/networknt/json-schema-validator](https://github.com/networknt/json-schema-validator) -library.\n\n\u003ca href=\"https://www.buymeacoffee.com/JanLoebel\" rel=\"Buy me a coffee!\"\u003e![Foo](https://cdn.buymeacoffee.com/buttons/default-orange.png)\u003c/a\u003e\n\n## Usage\n\nInclude the starter into you're project.\n\nYou need to add jitpack to your `pom.xml` because this project is not available in the official maven repository.\n```\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n_Note_: For Spring Boot \u003c 3.0 please use 2.3.0, otherwise use 3.x.x for Spring Boot \u003e= 3.0.\n\nAdd the `json-schema-validation-starter`-dependency to your `pom.xml`\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.JanLoebel\u003c/groupId\u003e\n    \u003cartifactId\u003ejson-schema-validation-starter\u003c/artifactId\u003e\n    \u003cversion\u003e3.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nAfter that simply create a json-schema and put it into e.g.: `resources/jsonschema/book.json`.\nThe last step is now to let your entity know that it should be validated and which schema it should use.\n\n```\n@JsonSchemaValidation(\"classpath:jsonschema/book.json\")\npublic class Book {\n    private String title;\n    private String author;\n}\n```\n\nAlternatively, you need to add this annotation in your controller like below. This is helpful when you generate your classes from a schema or can't edit them.\n\n```\n@RestController\n@RequestMapping(\"/books\")\npublic BooksConroller {\n     @PostMapping\n     public ResponseEntity\u003cBook\u003e createBook(@RequestBody @JsonSchemaValidation(\"classpath:jsonschema/book.json\") Book bookDto) {\n        //...\n        return bookDto;\n    }\n}\n```\n\nThe schemas are read by a bean that implements the `JsonSchemaProvider` interface. By default, the `DefaultJsonSchemaProvider` is used, which can load schemas by a URL or from the classpath. If necessary, a custom schema provider can be implemented and configured:\n\n```\n@ConditionalOnProperty(prefix = \"json.schema.validation\", name = \"schemaProvider\", havingValue = \"custom\")\n@Component\npublic class CustomJsonSchemaProvider implements JsonSchemaProvider {\n     JsonSchema loadSchema(String url) {\n         // Create and return a JSON schema...\n     }\n\n    void handleValidationMessages(Collection\u003cValidationMessage\u003e validationMessages) {\n         // Handle validation messages...\n    }\n}\n```\n\nConfigure the schema provider in `application.properties`:\n\n```\njson.schema.validation.schemaProvider=custom\n```\n\n## Example project\nHead over to [http://github.com/JanLoebel/json-schema-validation-starter-example](http://github.com/JanLoebel/json-schema-validation-starter-example) to checkout the sample project.\n\n## Contribution\nPlease feel free to improve or modify the code and open a Pull-Request! Any contribution is welcome :)\n\n## License\nMIT License\n\nCopyright (c) 2019 Jan Löbel\n\nSee LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanloebel%2Fjson-schema-validation-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanloebel%2Fjson-schema-validation-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanloebel%2Fjson-schema-validation-starter/lists"}