Skip to content

Commit 06f3db7

Browse files
authored
Merge pull request #675 from Azquelt/add-json-schema-dialect
Add json schema dialect property
2 parents e80e76c + f245695 commit 06f3db7

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

api/src/main/java/org/eclipse/microprofile/openapi/models/OpenAPI.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,36 @@ default OpenAPI webhooks(Map<String, PathItem> webhooks) {
327327
*/
328328
void removeWebhook(String name);
329329

330+
/**
331+
* Returns the default JSON Schema dialect for schemas in this document.
332+
*
333+
* @return the identifier of the default schema dialect for schemas in this document
334+
* @since 4.1
335+
*/
336+
String getJsonSchemaDialect();
337+
338+
/**
339+
* Sets the default JSON Schema dialect for schemas in this document.
340+
*
341+
* @param jsonSchemaDialect
342+
* the identifier of the default schema dialect for schemas in this document
343+
* @since 4.1
344+
*/
345+
void setJsonSchemaDialect(String jsonSchemaDialect);
346+
347+
/**
348+
* Sets the default JSON Schema dialect for schemas in this document.
349+
*
350+
* @param jsonSchemaDialect
351+
* the identifier of the default schema dialect for schemas in this document
352+
* @return the current OpenAPI object
353+
* @since 4.1
354+
*/
355+
default OpenAPI jsonSchemaDialect(String jsonSchemaDialect) {
356+
setJsonSchemaDialect(jsonSchemaDialect);
357+
return this;
358+
}
359+
330360
/**
331361
* Returns the components property from an OpenAPI instance.
332362
*

tck/src/main/java/org/eclipse/microprofile/openapi/reader/MyOASModelReaderImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ public OpenAPI buildModel() {
308308
.externalDocs(OASFactory.createObject(ExternalDocumentation.class)
309309
.description("instructions for how to deploy this app")
310310
.url("https://github.com/microservices-api/oas3-airlines/blob/master/README.md"))
311+
.jsonSchemaDialect("https://json-schema.org/draft/2020-12/schema")
311312
.addWebhook("bookingEvent", OASFactory.createPathItem()
312313
.PUT(OASFactory.createOperation()
313314
.summary("Notifies that a booking has been created")

tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelReaderAppTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,4 +427,10 @@ public void testRequestBodyInOperations(String type) {
427427

428428
vr.body("paths.'/zepplins'.delete.requestBody.content", notNullValue());
429429
}
430+
431+
@Test(dataProvider = "formatProvider")
432+
public void testSchemaDialect(String type) {
433+
ValidatableResponse vr = callEndpoint(type);
434+
vr.body("jsonSchemaDialect", equalTo("https://json-schema.org/draft/2020-12/schema"));
435+
}
430436
}

0 commit comments

Comments
 (0)