Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json schema dialect property #675

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@
*/
PathItem[] webhooks() default {};

/**
* The identifier of the default JSON schema dialect for schemas in this document.
*
* @return the identifier of the default JSON schema dialect for schemas in this document
*
* @since 4.1
*/
String jsonSchemaDialect() default "";

/**
* An element to hold a set of reusable objects for different aspects of the OpenAPI Specification (OAS).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
* </pre>
*/

@org.osgi.annotation.versioning.Version("1.2")
@org.osgi.annotation.versioning.Version("1.3")
package org.eclipse.microprofile.openapi.annotations;
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 @@ -40,6 +40,6 @@
* </pre>
*/

@org.osgi.annotation.versioning.Version("2.1")
@org.osgi.annotation.versioning.Version("2.2")
@org.osgi.annotation.versioning.ProviderType
package org.eclipse.microprofile.openapi.models;
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
},
components = @Components(schemas = {
@Schema(name = "Lizard", implementation = Lizard.class)
}))
}),
jsonSchemaDialect = "https://spec.openapis.org/oas/3.1/dialect/base")
@Schema(externalDocs = @ExternalDocumentation(url = "http://swagger.io", description = "Find out more about our store"))
public class PetStoreApp extends Application {
@Override
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"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,10 @@ public void testExtensionPlacement(String type) {
vr.body(opPath + ".responses.'503'.content.'application/xml'",
hasEntry(equalTo("x-notavailable-ext"), equalTo("true")));
}

@Test(dataProvider = "formatProvider")
public void testSchemaDialect(String type) {
ValidatableResponse vr = callEndpoint(type);
vr.body("jsonSchemaDialect", equalTo("https://spec.openapis.org/oas/3.1/dialect/base"));
}
}
Loading