Skip to content

Commit

Permalink
Merge pull request #625 from benjamin-confino/592-no-paths
Browse files Browse the repository at this point in the history
Test apps with no paths
  • Loading branch information
Azquelt authored May 31, 2024
2 parents 337f78d + d1a6ea8 commit 3ba3a3f
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 0 deletions.
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("admin@example.com")))
.components(OASFactory.createObject(Components.class)
.schemas(new HashMap<String, Schema>())
.addSchema("id", OASFactory.createObject(Schema.class)
.addType(Schema.SchemaType.INTEGER)
.format("int32")));
}
}
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://example.com/terms")
.contact(OASFactory.createObject(Contact.class)
.name("market API Support")
.url("http://example.com/contact")
.email("admin@example.com")))
.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")))));
}
}
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"));
}
}
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.MarketEvent.get.summary", equalTo("Notifies that a deal has been done"));
}
}
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 tck/src/main/resources/microprofile-reader-just-webhook.properties
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

0 comments on commit 3ba3a3f

Please sign in to comment.