Skip to content

Commit

Permalink
Merge pull request #675 from Azquelt/add-json-schema-dialect
Browse files Browse the repository at this point in the history
Add json schema dialect property
  • Loading branch information
Azquelt authored Jan 23, 2025
2 parents e80e76c + f245695 commit 06f3db7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,36 @@ default OpenAPI webhooks(Map<String, PathItem> webhooks) {
*/
void removeWebhook(String name);

/**
* Returns the default JSON Schema dialect for schemas in this document.
*
* @return the identifier of the default schema dialect for schemas in this document
* @since 4.1
*/
String getJsonSchemaDialect();

/**
* Sets the default JSON Schema dialect for schemas in this document.
*
* @param jsonSchemaDialect
* the identifier of the default schema dialect for schemas in this document
* @since 4.1
*/
void setJsonSchemaDialect(String jsonSchemaDialect);

/**
* Sets the default JSON Schema dialect for schemas in this document.
*
* @param jsonSchemaDialect
* the identifier of the default schema dialect for schemas in this document
* @return the current OpenAPI object
* @since 4.1
*/
default OpenAPI jsonSchemaDialect(String jsonSchemaDialect) {
setJsonSchemaDialect(jsonSchemaDialect);
return this;
}

/**
* Returns the components property from an OpenAPI instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ public OpenAPI buildModel() {
.externalDocs(OASFactory.createObject(ExternalDocumentation.class)
.description("instructions for how to deploy this app")
.url("https://github.com/microservices-api/oas3-airlines/blob/master/README.md"))
.jsonSchemaDialect("https://json-schema.org/draft/2020-12/schema")
.addWebhook("bookingEvent", OASFactory.createPathItem()
.PUT(OASFactory.createOperation()
.summary("Notifies that a booking has been created")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,10 @@ public void testRequestBodyInOperations(String type) {

vr.body("paths.'/zepplins'.delete.requestBody.content", notNullValue());
}

@Test(dataProvider = "formatProvider")
public void testSchemaDialect(String type) {
ValidatableResponse vr = callEndpoint(type);
vr.body("jsonSchemaDialect", equalTo("https://json-schema.org/draft/2020-12/schema"));
}
}

0 comments on commit 06f3db7

Please sign in to comment.