JSON Schemas
/actuator/jsonschemas shows the JSON Schemas of the application: the ones its registry holds, and the schema of every @Introspected class. Spring Boot has no such endpoint.
Why
"What JSON does this service accept and give?" is answered by a schema, and a running application can write it from its own classes. A client team can fetch the schema of Order from the service it calls, and you can check which schemas a deployed build really has: the ones from spring.json.schemas, the ones of your own customizers.
Example
# lib/resources/application.properties
management.endpoints.web.exposure.include=health,jsonschemas
$ curl localhost:8080/actuator/jsonschemas
{"registry": {
"resources:schemas/order.json": {"type": "object", "...": "..."}},
"introspected": {
"Book": {"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Book", "type": "object", "...": "..."}}}
One schema, by class name or by location:
$ curl localhost:8080/actuator/jsonschemas/Book
$ curl localhost:8080/actuator/jsonschemas/resources:schemas/order.json
What is listed
| Key | Content |
|---|---|
registry |
The schemas of the context's JsonSchemaRegistry, each by the location or $id it is known by: those of spring.json.schemas, of @JsonSchemaSource, of JsonSchema beans and of your own JsonSchemaRegistryCustomizer beans |
introspected |
The schema of every @Introspected class of the application, by class name, made from its introspection with the ObjectMapper's naming: what its JSON looks like |
- Without a registry bean,
registryis empty. introspectedleaves out enums and generic classes; of two classes with the same name it has the first. What a schema describes, and what it does not (polymorphism,@JsonUnwrapped), is on JSON Schema.
One schema
GET /actuator/jsonschemas/{name} gives one schema. The name is tried as a class name first, then as a location of the registry (the segments after jsonschemas/ are joined with /, so a location with slashes works). With no match the endpoint answers 404.
Exposure
The endpoint is enabled by default but, like every endpoint except health, not exposed over HTTP. Add jsonschemas to management.endpoints.web.exposure.include, or use *:
management.endpoints.web.exposure.include=health,jsonschemas
The schemas show the shape of your data and the places your application reads from, so protect the endpoint (see Security). management.endpoint.jsonschemas.access=none turns it off.
In Spring (Java)
Spring Boot Actuator has no counterpart. In Java a library writes the schema (Jackson's jsonSchema module, victools' jsonschema-generator) and the application serves it by hand.