Skip to content

Commit d1a6ea8

Browse files
Test apps with no paths
1 parent 337f78d commit d1a6ea8

6 files changed

+203
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.eclipse.microprofile.openapi.reader;
17+
18+
import java.util.HashMap;
19+
20+
import org.eclipse.microprofile.openapi.OASFactory;
21+
import org.eclipse.microprofile.openapi.OASModelReader;
22+
import org.eclipse.microprofile.openapi.models.Components;
23+
import org.eclipse.microprofile.openapi.models.OpenAPI;
24+
import org.eclipse.microprofile.openapi.models.info.Contact;
25+
import org.eclipse.microprofile.openapi.models.info.Info;
26+
import org.eclipse.microprofile.openapi.models.media.Schema;
27+
28+
public class MyOASModelReaderForJustComponentApp implements OASModelReader {
29+
30+
@Override
31+
public OpenAPI buildModel() {
32+
return OASFactory.createObject(OpenAPI.class)
33+
.info(OASFactory.createObject(Info.class)
34+
.title("MarketApp API")
35+
.version("1.0")
36+
.termsOfService("http://example.com/terms")
37+
.contact(OASFactory.createObject(Contact.class)
38+
.name("market API Support")
39+
.url("http://example.com/contact")
40+
.email("admin@example.com")))
41+
.components(OASFactory.createObject(Components.class)
42+
.schemas(new HashMap<String, Schema>())
43+
.addSchema("id", OASFactory.createObject(Schema.class)
44+
.addType(Schema.SchemaType.INTEGER)
45+
.format("int32")));
46+
}
47+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.eclipse.microprofile.openapi.reader;
17+
18+
import org.eclipse.microprofile.openapi.OASFactory;
19+
import org.eclipse.microprofile.openapi.OASModelReader;
20+
import org.eclipse.microprofile.openapi.models.OpenAPI;
21+
import org.eclipse.microprofile.openapi.models.info.Contact;
22+
import org.eclipse.microprofile.openapi.models.info.Info;
23+
24+
public class MyOASModelReaderForJustWebHookApp implements OASModelReader {
25+
26+
@Override
27+
public OpenAPI buildModel() {
28+
return OASFactory.createObject(OpenAPI.class)
29+
.info(OASFactory.createObject(Info.class)
30+
.title("MarketApp API")
31+
.version("1.0")
32+
.termsOfService("http://example.com/terms")
33+
.contact(OASFactory.createObject(Contact.class)
34+
.name("market API Support")
35+
.url("http://example.com/contact")
36+
.email("admin@example.com")))
37+
.addWebhook("MarketEvent", OASFactory.createPathItem()
38+
.GET(OASFactory.createOperation()
39+
.summary("Notifies that a deal has been done")
40+
.responses(OASFactory.createAPIResponses()
41+
.addAPIResponse("202", OASFactory.createAPIResponse()
42+
.description(
43+
"Indicates that the deal was processed successfully")))));
44+
}
45+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.eclipse.microprofile.openapi.tck;
18+
19+
import static org.hamcrest.Matchers.equalTo;
20+
21+
import org.jboss.arquillian.container.test.api.Deployment;
22+
import org.jboss.shrinkwrap.api.ShrinkWrap;
23+
import org.jboss.shrinkwrap.api.spec.WebArchive;
24+
import org.testng.annotations.Test;
25+
26+
import io.restassured.response.ValidatableResponse;
27+
28+
public class ModelReaderAppWithJustComponentTest extends AppTestBase {
29+
@Deployment(name = "airlinesModelReader", testable = false)
30+
public static WebArchive createDeployment() {
31+
return ShrinkWrap.create(WebArchive.class, "noPathsAppReader.war")
32+
.addPackages(true, "org.eclipse.microprofile.openapi.reader")
33+
.addAsManifestResource("microprofile-reader-just-component.properties",
34+
"microprofile-config.properties");
35+
}
36+
37+
@Test(dataProvider = "formatProvider")
38+
public void testDocumentCreated(String type) {
39+
ValidatableResponse vr = callEndpoint(type);
40+
vr.body("components.schemas.id.format", equalTo("int32"));
41+
}
42+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.eclipse.microprofile.openapi.tck;
18+
19+
import static org.hamcrest.Matchers.equalTo;
20+
21+
import org.jboss.arquillian.container.test.api.Deployment;
22+
import org.jboss.shrinkwrap.api.ShrinkWrap;
23+
import org.jboss.shrinkwrap.api.spec.WebArchive;
24+
import org.testng.annotations.Test;
25+
26+
import io.restassured.response.ValidatableResponse;
27+
28+
public class ModelReaderAppWithJustWebHookTest extends AppTestBase {
29+
@Deployment(name = "airlinesModelReader", testable = false)
30+
public static WebArchive createDeployment() {
31+
return ShrinkWrap.create(WebArchive.class, "noPathsAppReader.war")
32+
.addPackages(true, "org.eclipse.microprofile.openapi.reader")
33+
.addAsManifestResource("microprofile-reader-just-webhook.properties", "microprofile-config.properties");
34+
}
35+
36+
@Test(dataProvider = "formatProvider")
37+
public void testDocumentCreated(String type) {
38+
ValidatableResponse vr = callEndpoint(type);
39+
vr.body("webhooks.MarketEvent.get.summary", equalTo("Notifies that a deal has been done"));
40+
}
41+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
2+
# <p>
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
# <p>
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# <p>
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
mp.openapi.model.reader=org.eclipse.microprofile.openapi.reader.MyOASModelReaderForJustComponentApp
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
2+
# <p>
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
# <p>
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# <p>
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
mp.openapi.model.reader=org.eclipse.microprofile.openapi.reader.MyOASModelReaderForJustWebHookApp

0 commit comments

Comments
 (0)