Skip to content
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

Map-backed OAS model classes from annotations #2021

Merged
merged 6 commits into from
Oct 23, 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
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ jobs:
#- tck-version: "2.0.1"
#- tck-version: "3.0"
#- tck-version: "3.1.1"
- tck-version: "4.0.1"
- title: "4.0.x"
tck-version: "4.0.2"

name: MicroProfile OpenAPI TCK ${{ matrix.tck-version }}
name: MicroProfile OpenAPI TCK ${{ matrix.title }}
steps:
- uses: actions/checkout@v4
name: checkout
Expand Down
12 changes: 8 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ mvn clean install
* link:extension-spring[extension-spring] - The Spring entry point. This module depends on Spring and core.
* link:extension-vertx[extension-vertx] - The Vert.x entry point. This module depends on Vert.x and core.
* link:implementation[implementation] - Implementation of the Eclipse MicroProfile OpenAPI specification. This just pulls in Core and the JAX-RS extension .
* link:model[model] - Base model classes used by core and extensions to represent an OpenAPI document
* link:testsuite[testsuite] - Test Suites and Data
** link:testsuite/tck[tck] - Test suite to run the implementation against the Eclipse MicroProfile OpenAPI TCK.
** link:testsuite/extra[extra] - Extra integration tests not related to the TCK.
** link:testsuite/data[data] - Quarkus application with tests to verify additional annotation scanning scenarios
** link:testsuite/coverage[coverage] - Test coverage report aggregator for other modules
* link:tools/maven-plugin[maven-plugin] - Maven plugin that creates the OpenAPI Schema on build.
** link:testsuite/data[data] - Quarkus application with tests to verify additional annotation scanning scenarios
** link:testsuite/extra[extra] - Extra integration tests not related to the TCK.
** link:testsuite/tck[tck] - Test suite to run the implementation against the Eclipse MicroProfile OpenAPI TCK.
* link:tools[tools]
** link:tools/gradle-plugin[gradle-plugin] - Gradle plugin that creates the OpenAPI Schema on build.
** link:tools/maven-plugin[maven-plugin] - Maven plugin that creates the OpenAPI Schema on build.
** link:tools/model-apt[model-apt] - APT processor to generate model classes (in core) based on annotations (not for general-purpose use)

=== Links

Expand Down
11 changes: 11 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
<artifactId>microprofile-config-api</artifactId>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>smallrye-open-api-model</artifactId>
</dependency>

<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-open-api-model-apt</artifactId>
<scope>provided</scope>
</dependency>

<!-- Third Party Libraries -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
10 changes: 4 additions & 6 deletions core/src/main/java/io/smallrye/openapi/api/OpenApiDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import java.util.LinkedHashMap;
import java.util.Map;

import org.eclipse.microprofile.openapi.OASFactory;
import org.eclipse.microprofile.openapi.OASFilter;
import org.eclipse.microprofile.openapi.models.OpenAPI;

import io.smallrye.openapi.api.models.OpenAPIImpl;
import io.smallrye.openapi.api.models.PathsImpl;
import io.smallrye.openapi.api.models.info.InfoImpl;
import io.smallrye.openapi.api.util.ConfigUtil;
import io.smallrye.openapi.api.util.FilterUtil;
import io.smallrye.openapi.api.util.MergeUtil;
Expand Down Expand Up @@ -144,17 +142,17 @@ public synchronized void initialize() {

// Phase 5: Default empty document if model == null
if (merged == null) {
merged = new OpenAPIImpl();
merged = OASFactory.createOpenAPI();
merged.setOpenapi(SmallRyeOASConfig.Defaults.VERSION);
}

// Phase 6: Provide missing required elements using defaults
if (defaultRequiredProperties) {
if (merged.getPaths() == null) {
merged.setPaths(new PathsImpl());
merged.setPaths(OASFactory.createPaths());
}
if (merged.getInfo() == null) {
merged.setInfo(new InfoImpl());
merged.setInfo(OASFactory.createInfo());
}
if (merged.getInfo().getTitle() == null) {
merged.getInfo().setTitle((archiveName == null ? "Generated" : archiveName) + " API");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.eclipse.microprofile.openapi.OASFactory;
import org.eclipse.microprofile.openapi.OASFilter;
import org.eclipse.microprofile.openapi.models.Components;
import org.eclipse.microprofile.openapi.models.OpenAPI;
Expand All @@ -30,7 +31,6 @@
import org.jboss.jandex.Indexer;
import org.jboss.jandex.Type;

import io.smallrye.openapi.api.models.OpenAPIImpl;
import io.smallrye.openapi.api.util.MergeUtil;
import io.smallrye.openapi.runtime.OpenApiProcessor;
import io.smallrye.openapi.runtime.OpenApiRuntimeException;
Expand Down Expand Up @@ -599,7 +599,7 @@ protected <V, A extends V, O extends V, AB, OB> void buildAnnotationModel(BuildC
ctx.buildConfig.setAllowNakedPathParameter(enableUnannotatedPathParameters);
AnnotationScannerExtension ext = newExtension(ctx.modelIO);
AnnotationScannerContext scannerContext = new AnnotationScannerContext(ctx.filteredIndex, ctx.appClassLoader,
Collections.singletonList(ext), false, ctx.buildConfig, operationHandler, new OpenAPIImpl());
Collections.singletonList(ext), false, ctx.buildConfig, operationHandler, OASFactory.createOpenAPI());
ctx.modelIO.ioContext().scannerContext(scannerContext);
Supplier<Iterable<AnnotationScanner>> supplier = Optional.ofNullable(scannerClassLoader)
.map(AnnotationScannerFactory::new)
Expand Down
Loading