-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
337f78d
commit 11da26d
Showing
6 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...ain/java/org/eclipse/microprofile/openapi/reader/MyOASModelReaderForJustComponentApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.eclipse.microprofile.openapi.reader; | ||
|
||
import java.util.HashMap; | ||
|
||
import org.eclipse.microprofile.openapi.OASFactory; | ||
import org.eclipse.microprofile.openapi.OASModelReader; | ||
import org.eclipse.microprofile.openapi.models.Components; | ||
import org.eclipse.microprofile.openapi.models.OpenAPI; | ||
import org.eclipse.microprofile.openapi.models.info.Contact; | ||
import org.eclipse.microprofile.openapi.models.info.Info; | ||
import org.eclipse.microprofile.openapi.models.media.Schema; | ||
|
||
public class MyOASModelReaderForJustComponentApp implements OASModelReader { | ||
|
||
@Override | ||
public OpenAPI buildModel() { | ||
return OASFactory.createObject(OpenAPI.class) | ||
.info(OASFactory.createObject(Info.class) | ||
.title("MarketApp API") | ||
.version("1.0") | ||
.termsOfService("http://example.com/terms") | ||
.contact(OASFactory.createObject(Contact.class) | ||
.name("market API Support") | ||
.url("http://example.com/contact") | ||
.email("[email protected]"))) | ||
.components(OASFactory.createObject(Components.class) | ||
.schemas(new HashMap<String, Schema>()) | ||
.addSchema("id", OASFactory.createObject(Schema.class) | ||
.addType(Schema.SchemaType.INTEGER) | ||
.format("int32"))); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
.../main/java/org/eclipse/microprofile/openapi/reader/MyOASModelReaderForJustWebHookApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.eclipse.microprofile.openapi.reader; | ||
|
||
import org.eclipse.microprofile.openapi.OASFactory; | ||
import org.eclipse.microprofile.openapi.OASModelReader; | ||
import org.eclipse.microprofile.openapi.models.OpenAPI; | ||
import org.eclipse.microprofile.openapi.models.info.Contact; | ||
import org.eclipse.microprofile.openapi.models.info.Info; | ||
|
||
public class MyOASModelReaderForJustWebHookApp implements OASModelReader { | ||
|
||
@Override | ||
public OpenAPI buildModel() { | ||
return OASFactory.createObject(OpenAPI.class) | ||
.info(OASFactory.createObject(Info.class) | ||
.title("MarketApp API") | ||
.version("1.0") | ||
.termsOfService("http://market.com/terms") | ||
.contact(OASFactory.createObject(Contact.class) | ||
.name("market API Support") | ||
.url("http://example.com/contact") | ||
.email("[email protected]"))) | ||
.addWebhook("MarketEvent", OASFactory.createPathItem() | ||
.GET(OASFactory.createOperation() | ||
.summary("Notifies that a deal has been done") | ||
.responses(OASFactory.createAPIResponses() | ||
.addAPIResponse("202", OASFactory.createAPIResponse() | ||
.description( | ||
"Indicates that the deal was processed successfully"))))); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...c/main/java/org/eclipse/microprofile/openapi/tck/ModelReaderAppWithJustComponentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.eclipse.microprofile.openapi.tck; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.testng.annotations.Test; | ||
|
||
import io.restassured.response.ValidatableResponse; | ||
|
||
public class ModelReaderAppWithJustComponentTest extends AppTestBase { | ||
@Deployment(name = "airlinesModelReader", testable = false) | ||
public static WebArchive createDeployment() { | ||
return ShrinkWrap.create(WebArchive.class, "noPathsAppReader.war") | ||
.addPackages(true, "org.eclipse.microprofile.openapi.reader") | ||
.addAsManifestResource("microprofile-reader-just-component.properties", | ||
"microprofile-config.properties"); | ||
} | ||
|
||
@Test(dataProvider = "formatProvider") | ||
public void testDocumentCreated(String type) { | ||
ValidatableResponse vr = callEndpoint(type); | ||
vr.body("components.schemas.id.format", equalTo("int32")); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...src/main/java/org/eclipse/microprofile/openapi/tck/ModelReaderAppWithJustWebHookTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.eclipse.microprofile.openapi.tck; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.testng.annotations.Test; | ||
|
||
import io.restassured.response.ValidatableResponse; | ||
|
||
public class ModelReaderAppWithJustWebHookTest extends AppTestBase { | ||
@Deployment(name = "airlinesModelReader", testable = false) | ||
public static WebArchive createDeployment() { | ||
return ShrinkWrap.create(WebArchive.class, "noPathsAppReader.war") | ||
.addPackages(true, "org.eclipse.microprofile.openapi.reader") | ||
.addAsManifestResource("microprofile-reader-just-webhook.properties", "microprofile-config.properties"); | ||
} | ||
|
||
@Test(dataProvider = "formatProvider") | ||
public void testDocumentCreated(String type) { | ||
ValidatableResponse vr = callEndpoint(type); | ||
vr.body("webhooks.blackMarketEvent.get.summary", equalTo("Notifies that a illicit deal has been done")); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tck/src/main/resources/microprofile-reader-just-component.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# <p> | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# <p> | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# <p> | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
mp.openapi.model.reader=org.eclipse.microprofile.openapi.reader.MyOASModelReaderForJustComponentApp |
14 changes: 14 additions & 0 deletions
14
tck/src/main/resources/microprofile-reader-just-webhook.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# <p> | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# <p> | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# <p> | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
mp.openapi.model.reader=org.eclipse.microprofile.openapi.reader.MyOASModelReaderForJustWebHookApp |