{"id":18743939,"url":"https://github.com/victools/jsonschema-gradle-example","last_synced_at":"2026-05-17T09:47:33.119Z","repository":{"id":119345483,"uuid":"300876978","full_name":"victools/jsonschema-gradle-example","owner":"victools","description":"Minimal example show-casing how the Java JSON Schema Generator can be used within a gradle build","archived":false,"fork":false,"pushed_at":"2020-10-03T12:41:30.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-04T16:41:14.323Z","etag":null,"topics":["gradle","json-schema","jsonschema-generator"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/victools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2020-10-03T12:37:41.000Z","updated_at":"2024-01-29T08:45:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"134be093-151f-4524-8527-a94b84874459","html_url":"https://github.com/victools/jsonschema-gradle-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/victools/jsonschema-gradle-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victools%2Fjsonschema-gradle-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victools%2Fjsonschema-gradle-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victools%2Fjsonschema-gradle-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victools%2Fjsonschema-gradle-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/victools","download_url":"https://codeload.github.com/victools/jsonschema-gradle-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victools%2Fjsonschema-gradle-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007043,"owners_count":26084227,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["gradle","json-schema","jsonschema-generator"],"created_at":"2024-11-07T16:13:12.530Z","updated_at":"2025-10-20T08:11:38.481Z","avatar_url":"https://github.com/victools.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java JSON Schema Generator – Gradle Example\n\nMinimal example show-casing how the Java JSON Schema Generator can be used within a gradle build.\n\n----\n\n## Usage\nDepending on your OS either use the `gradlew` or `gradlew.bat` executable in the project directory.\n\nExecute the following command:\n```zsh\n./gradlew -q generate\n```\nThis will generate a schema (here for the `SchemaVersion` enum) and write it to a `schema.json` file in the project directory.\nIn this particular example, the schema is also printed to the console:\n```\njsonschema-gradle-example % ./gradlew -q generate\n{\n  \"$schema\" : \"https://json-schema.org/draft/2019-09/schema\",\n  \"type\" : \"string\",\n  \"enum\" : [ \"DRAFT_6\", \"DRAFT_7\", \"DRAFT_2019_09\" ]\n}\n```\n\n## Content of `build.gradle`\nFor your convenience, here is the full content of the `build.gradle` file representing this example:\n```groovy\nimport com.github.victools.jsonschema.generator.OptionPreset;\nimport com.github.victools.jsonschema.generator.SchemaGenerator;\nimport com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder;\nimport com.github.victools.jsonschema.generator.SchemaVersion;\n\nbuildscript {\n    repositories {\n        mavenCentral()\n    }\n    dependencies {\n        classpath group: 'com.github.victools', name: 'jsonschema-generator', version: '4.16.0'\n    }\n}\nplugins {\n    id 'java-library'\n}\n\ntask generate {\n    doLast {\n        def configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2019_09, OptionPreset.PLAIN_JSON);\n        // apply your configurations here\n        def generator = new SchemaGenerator(configBuilder.build());\n        // target the class for which to generate a schema\n        def jsonSchema = generator.generateSchema(SchemaVersion.class);\n        // handle generated schema, e.g. write it to the console or a file\n        def jsonSchemaAsString = jsonSchema.toPrettyString();\n        println jsonSchemaAsString\n        new File(projectDir, \"schema.json\").text = jsonSchemaAsString\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictools%2Fjsonschema-gradle-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvictools%2Fjsonschema-gradle-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictools%2Fjsonschema-gradle-example/lists"}