Skip to content

Add Identifier field to License #611

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

Merged
merged 2 commits into from
May 15, 2024
Merged
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 @@ -40,6 +40,13 @@
**/
String name();

/**
* The license identifier used for the API.
*
* @return the identifier of the license
**/
String identifier() default "";

/**
* A URL to the license used for the API. MUST be in the format of a URL.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ default License name(String name) {
return this;
}

/**
* Returns the license identifier for this License instance that is used for the API.
*
* @return the license identifier used for the API
**/
String getIdentifier();

/**
* Sets the license identifier for this License instance that is used for the API.
*
* @param identifier
* the license identifier used for the API
*/
void setIdentifier(String identifier);

/**
* Sets this License instance's identifier used for the API and returns this instance of License.
*
* @param identifier
* the license identifier used for the API
* @return this License instance
*/
default License identifier(String identifier) {
setIdentifier(identifier);
return this;
}

/**
* Returns the URL for this License instance that is used for the API.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@ApplicationPath("/")
@OpenAPIDefinition(info = @Info(title = "Pet Store App", version = "2.0", description = "Pet Store App API",
license = @License(name = "Apache 2.0",
url = "http://www.apache.org/licenses/LICENSE-2.0.html"),
identifier = "Apache-2.0"),
contact = @Contact(name = "PetStore API Support",
url = "https://github.com/eclipse/microprofile-open-api",
email = "[email protected]"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ public void setUrl(String url) {
public License url(String url) {
return null;
}
@Override
public String getIdentifier() {
return null;
}
@Override
public void setIdentifier(String identifier) {
}
}

@Deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public static WebArchive createDeployment() {
.addPackages(true, "org.eclipse.microprofile.openapi.apps.petstore");
}

// This test covers basic OpenAPI ingredients like licenses, if something is here instead of tested in the
// AirlinesApp
// It is likely because it is mutually exclusive with something in the AirlinesApp
@Test(dataProvider = "formatProvider")
public void testOpenAPIEssentials(String type) {
ValidatableResponse vr = callEndpoint(type);

vr.body("info.license.identifier", equalTo("Apache-2.0"));
}

@Test(dataProvider = "formatProvider")
public void testSchema(String type) {
ValidatableResponse vr = callEndpoint(type);
Expand Down
Loading