Skip to content

Commit

Permalink
OpenAPI FAT tests for annotation usage warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Azquelt committed Jan 9, 2025
1 parent d3afb56 commit bb6bb81
Show file tree
Hide file tree
Showing 10 changed files with 452 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#*******************************************************************************
# Copyright (c) 2024 IBM Corporation and others.
# Copyright (c) 2024, 2025 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
Expand All @@ -17,3 +17,8 @@ src: \
fat/src

fat.project: true

-buildpath: \
com.ibm.websphere.javaee.jsonp.1.1,\
io.openliberty.org.eclipse.microprofile.openapi.4.0;version=latest,\
io.openliberty.jakarta.restfulWS.3.1;version=latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

dependencies {
requiredLibs project(path: ':io.openliberty.org.eclipse.microprofile', configuration: 'openapi40')
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 IBM Corporation and others.
* Copyright (c) 2024, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -20,6 +20,7 @@
import io.openliberty.microprofile.openapi40.fat.validation.ValidationTestNoErrors;
import io.openliberty.microprofile.openapi40.fat.validation.ValidationTestOne;
import io.openliberty.microprofile.openapi40.fat.validation.ValidationTestTwo;
import io.openliberty.microprofile.openapi40.fat.versionwarning.VersionWarningTest;

@SuiteClasses({
ValidationTestOne.class,
Expand All @@ -28,7 +29,8 @@
ValidationTestFour.class,
ValidationTestFive.class,
ValidationTestNoErrors.class,
ValidationTestCrossVersion.class
ValidationTestCrossVersion.class,
VersionWarningTest.class,
})
@RunWith(Suite.class)
public class FATSuite {}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package io.openliberty.microprofile.openapi40.fat.versionwarning.app;

import org.eclipse.microprofile.openapi.annotations.Components;
import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition;
import org.eclipse.microprofile.openapi.annotations.PathItem;
import org.eclipse.microprofile.openapi.annotations.PathItemOperation;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.info.Info;
import org.eclipse.microprofile.openapi.annotations.info.License;
import org.eclipse.microprofile.openapi.annotations.media.DependentRequired;
import org.eclipse.microprofile.openapi.annotations.media.DependentSchema;
import org.eclipse.microprofile.openapi.annotations.media.PatternProperty;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.media.SchemaProperty;

import io.openliberty.microprofile.openapi40.fat.versionwarning.app.VersionWarningDataObject.SubschemaA;
import io.openliberty.microprofile.openapi40.fat.versionwarning.app.VersionWarningDataObject.SubschemaB;
import io.openliberty.microprofile.openapi40.fat.versionwarning.app.VersionWarningDataObject.SubschemaC;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("/")
@OpenAPIDefinition(info = @Info(title = "test", version = "0.1", summary = "test",
license = @License(name = "Example License 1.0", identifier = "EXAMPLE-1.0")),
components = @Components(pathItems = @PathItem(name = "testPathItem",
operations = @PathItemOperation(method = "GET",
description = "example callback operation")),
schemas = @Schema(name = "componentSchema",
properties = { @SchemaProperty(name = "prop1",
type = SchemaType.OBJECT,
comment = "testComment",
additionalProperties = VersionWarningDataObject.class,
ifSchema = SubschemaA.class,
thenSchema = SubschemaB.class,
elseSchema = SubschemaC.class,
dependentSchemas = @DependentSchema(name = "prop2",
schema = SubschemaA.class)),
@SchemaProperty(name = "prop2",
contains = SubschemaA.class,
minContains = 1,
maxContains = 6,
prefixItems = { SubschemaB.class,
SubschemaB.class }),
@SchemaProperty(name = "prop3",
type = SchemaType.OBJECT,
patternProperties = @PatternProperty(regex = "test\\..*",
schema = SubschemaA.class),
dependentRequired = @DependentRequired(name = "prop2",
requires = "prop3"),
propertyNames = SubschemaC.class),
@SchemaProperty(name = "prop4",
type = SchemaType.STRING,
contentEncoding = "base64",
contentMediaType = "application/json",
contentSchema = SubschemaC.class)
})),
webhooks = @PathItem(name = "testWebhook"))
public class VersionWarningApplication extends Application {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package io.openliberty.microprofile.openapi40.fat.versionwarning.app;

import java.util.List;

import org.eclipse.microprofile.openapi.annotations.media.DependentRequired;
import org.eclipse.microprofile.openapi.annotations.media.DependentSchema;
import org.eclipse.microprofile.openapi.annotations.media.PatternProperty;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import io.openliberty.microprofile.openapi40.fat.versionwarning.app.VersionWarningDataObject.SubschemaA;
import io.openliberty.microprofile.openapi40.fat.versionwarning.app.VersionWarningDataObject.SubschemaB;
import io.openliberty.microprofile.openapi40.fat.versionwarning.app.VersionWarningDataObject.SubschemaC;

@Schema(comment = "test comment",
constValue = "3",
ifSchema = SubschemaA.class,
thenSchema = SubschemaB.class,
elseSchema = SubschemaC.class,
dependentSchemas = @DependentSchema(name = "test", schema = SubschemaC.class),
patternProperties = @PatternProperty(regex = "testPattern", schema = SubschemaC.class),
dependentRequired = @DependentRequired(name = "testA", requires = { "testB", "testC" }),
propertyNames = SubschemaB.class)
public class VersionWarningDataObject {

public static class SubschemaA {}

public static class SubschemaB {}

public static class SubschemaC {}

@Schema(contains = SubschemaC.class, minContains = 1, maxContains = 6, prefixItems = { SubschemaA.class, SubschemaA.class })
private List<String> testList;

@Schema(contentEncoding = "base64", contentMediaType = "application/json", contentSchema = SubschemaC.class)
private String encodedTest;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package io.openliberty.microprofile.openapi40.fat.versionwarning.app;

import org.eclipse.microprofile.openapi.annotations.callbacks.Callback;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

@Path("/")
public class VersionWarningResource {

@GET
@Callback(name = "test", callbackUrlExpression = "/callback/test", pathItemRef = "testPathItem")
public String getTest() {
return "test";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bootstrap.include=../testports.properties
com.ibm.ws.logging.trace.specification=*=info=enabled:mpOpenAPI=debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<server description="Server for OpenAPI model validation testing">

<!-- Enable features -->
<featureManager>
<feature>mpOpenAPI-4.0</feature>
<feature>componenttest-2.0</feature>
<feature>restfulWS-3.1</feature> <!-- EE feature to ensure we get the expected EE version -->
<feautre>mpConfig-3.1</feautre>
</featureManager>

<include location="../fatTestPorts.xml" />

</server>
6 changes: 5 additions & 1 deletion dev/io.openliberty.org.eclipse.microprofile/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2024 IBM Corporation and others.
* Copyright (c) 2020, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -32,6 +32,9 @@ configurations {
openapi20 {
canBeResolved = true
}
openapi40 {
canBeResolved = true
}
}

artifacts {
Expand All @@ -42,4 +45,5 @@ artifacts {
contextpropagation13(file('build/libs/io.openliberty.org.eclipse.microprofile.contextpropagation.1.3.jar'))
health31(file('build/libs/io.openliberty.org.eclipse.microprofile.health.3.1.jar'))
openapi20(file('build/libs/io.openliberty.org.eclipse.microprofile.openapi.2.0.jar'))
openapi40(file('build/libs/io.openliberty.org.eclipse.microprofile.openapi.4.0.jar'))
}

0 comments on commit bb6bb81

Please sign in to comment.