https://github.com/alexmond/spring-boot-config-json-schema
A Spring Boot starter that auto-generates JSON Schema for application.yaml or application.properties from @ConfigurationProperties. Simplifies configuration documentation and validation, with support for IDE autocompletion (e.g., IntelliJ, VS Code) and CI/CD pipelines.
https://github.com/alexmond/spring-boot-config-json-schema
java json-schema spring-boot spring-boot-starter
Last synced: 2 months ago
JSON representation
A Spring Boot starter that auto-generates JSON Schema for application.yaml or application.properties from @ConfigurationProperties. Simplifies configuration documentation and validation, with support for IDE autocompletion (e.g., IntelliJ, VS Code) and CI/CD pipelines.
- Host: GitHub
- URL: https://github.com/alexmond/spring-boot-config-json-schema
- Owner: alexmond
- License: apache-2.0
- Created: 2025-08-01T04:51:44.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-03-14T02:36:39.000Z (3 months ago)
- Last Synced: 2026-04-03T02:33:57.342Z (3 months ago)
- Topics: java, json-schema, spring-boot, spring-boot-starter
- Language: Java
- Homepage: https://www.alexmond.org/spring-boot-config-json-schema-starter/current/index.html
- Size: 974 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.adoc
- Changelog: CHANGELOG.adoc
- Contributing: CONTRIBUTING.adoc
- License: LICENSE
Awesome Lists containing this project
README
:version: 3.5.10.1
= Spring Boot Config JSON Schema Generator
:toc:
image:https://img.shields.io/maven-central/v/org.alexmond/spring-boot-config-json-schema-starter.svg?label=Maven%20Central[Maven Central,link=https://search.maven.org/artifact/org.alexmond/spring-boot-config-json-schema-starter]
image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[License,link=LICENSE]
image:https://img.shields.io/github/actions/workflow/status/alexmond/spring-boot-config-json-schema/maven.yml[Build Status,link=https://github.com/alexmond/spring-boot-config-json-schema/actions]
image:https://codecov.io/gh/alexmond/spring-boot-config-json-schema/graph/badge.svg?token=C4IEMB36WJ[codecov,link=https://codecov.io/gh/alexmond/spring-boot-config-json-schema]
== Spring Boot Config JSON Schema Generator
A Spring Boot starter library that automatically generates JSON Schema documentation for your application's configuration properties.
It simplifies the process of documenting and validating configuration by generating JSON Schema from your Spring Boot configuration classes.
For detailed documentation, please visit our link:https://www.alexmond.org/spring-boot-config-json-schema-starter/current/index.html[full documentation].
A good article on this subject: link:https://themightyprogrammer.dev/article/2ways-spring-configuration[Spring Boot Config Documentation, Two Ways With IntelliJ IDEA]
[[quick-start]]
== Quick Start
[[maven-dependencies]]
=== Maven Dependencies
==== For Testing
Add the following dependency to your `pom.xml` when using the generator in tests:
[source,xml,subs=+attributes]
----
org.alexmond
spring-boot-config-json-schema-starter
{version}
test
----
[source,java]
----
@SpringBootTest
@Slf4j
class SampleJsonSchemaGeneratorTests {
@Autowired
private JsonSchemaService jsonSchemaService;
@Test
void generateJsonSchema() {
var jsonConfigSchemaJson = jsonSchemaService.generateFullSchemaJson();
var jsonConfigSchemaYaml = jsonSchemaService.generateFullSchemaYaml();
log.info("Writing json schema");
Files.writeString(Paths.get("config-schema.json"), jsonConfigSchemaJson, StandardCharsets.UTF_8);
log.info("Writing yaml schema");
Files.writeString(Paths.get("config-schema.yaml"), jsonConfigSchemaYaml, StandardCharsets.UTF_8);
}
}
----
[[for-production-rest-or-actuator]]
=== For Production (REST or Actuator)
==== REST API Endpoint
To expose the JSON schema via a REST endpoint (similar to Swagger API docs), add the following dependency to your
`pom.xml`:
[source,xml,subs=+attributes]
----
org.alexmond
spring-boot-config-json-schema-starter
{version}
----
Then create a REST controller:
[source,java]
----
@RestController
@Slf4j
public class GenerateJsonSchema {
@Autowired
private JsonSchemaService jsonSchemaService;
@GetMapping("/config-schema")
public String getConfigSchema() {
return jsonSchemaService.generateFullSchemaJson();
}
@GetMapping("/config-schema.yaml")
public String getConfigSchemaYaml() {
return jsonSchemaService.generateFullSchemaYaml();
}
}
----
==== Actuator Endpoint
To expose the JSON schema via an Actuator endpoint, add the following dependency to your
`pom.xml`:
[source,xml,subs=+attributes]
----
org.alexmond
spring-boot-config-json-schema-starter
{version}
----
Then create Actuator endpoint:
[source,java]
----
@Component
@Endpoint(id = "config-schema")
@RequiredArgsConstructor
public class ConfigSchemaEndpoint {
private final JsonSchemaService jsonSchemaService;
@ReadOperation
public String schema() {
return jsonSchemaService.generateFullSchemaJson();
}
}
----
[source,java]
----
@Component
@Endpoint(id = "config-schema.yaml")
@RequiredArgsConstructor
public class ConfigSchemaYamlEndpoint {
private final JsonSchemaService jsonSchemaService;
@ReadOperation
public String schema() {
return jsonSchemaService.generateFullSchemaYaml();
}
}
----
Configure in `application.yaml`:
[source,yaml]
----
management:
endpoints:
web:
exposure:
include: config-schema
----
[[changelog]]
== Changelog
include::CHANGELOG.adoc[]
[[contributing]]
== Contributing
Contributions welcome!
See link:CONTRIBUTING.adoc[CONTRIBUTING] for guidelines.
Open issues for bugs or feature requests ( e.g., IDE enhancements, validation support).
[[license]]
== License
Licensed under link:LICENSE[Apache 2.0 License].
'''
⭐ Star this repo if you find it useful!
Share feedback via [issues](https://github.com/alexmond/spring-boot-config-json-schema/issues).