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

Bump smallrye-open-api from 3.4.0 to 3.5.0 #35102

Merged
merged 1 commit into from
Jul 31, 2023
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
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<smallrye-config.version>3.3.2</smallrye-config.version>
<smallrye-health.version>4.0.2</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.4.0</smallrye-open-api.version>
<smallrye-open-api.version>3.5.0</smallrye-open-api.version>
<smallrye-graphql.version>2.2.1</smallrye-graphql.version>
<smallrye-opentracing.version>3.0.3</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>6.2.6</smallrye-fault-tolerance.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ public void build(BuildProducer<FeatureBuildItem> feature,
} else {
annotationModel = new OpenAPIImpl();
}
OpenApiDocument finalDocument = loadDocument(staticModel, annotationModel, openAPIBuildItems);
OpenApiDocument finalDocument = loadDocument(staticModel, annotationModel, openAPIBuildItems, index);

for (Format format : Format.values()) {
String name = OpenApiConstants.BASE_NAME + format;
Expand All @@ -806,7 +806,7 @@ public void build(BuildProducer<FeatureBuildItem> feature,
nativeImageResources.produce(new NativeImageResourceBuildItem(name));
}

OpenApiDocument finalStoredOpenApiDocument = storeDocument(out, smallRyeOpenApiConfig, finalDocument.get());
OpenApiDocument finalStoredOpenApiDocument = storeDocument(out, smallRyeOpenApiConfig, index, finalDocument.get());
openApiDocumentProducer.produce(new OpenApiDocumentBuildItem(finalStoredOpenApiDocument));
}

Expand Down Expand Up @@ -1067,8 +1067,8 @@ static class Result {
}

private OpenApiDocument loadDocument(OpenAPI staticModel, OpenAPI annotationModel,
List<AddToOpenAPIDefinitionBuildItem> openAPIBuildItems) {
OpenApiDocument document = prepareOpenApiDocument(staticModel, annotationModel, openAPIBuildItems);
List<AddToOpenAPIDefinitionBuildItem> openAPIBuildItems, IndexView index) {
OpenApiDocument document = prepareOpenApiDocument(staticModel, annotationModel, openAPIBuildItems, index);

Config c = ConfigProvider.getConfig();
String title = c.getOptionalValue("quarkus.application.name", String.class).orElse("Generated");
Expand All @@ -1083,22 +1083,24 @@ private OpenApiDocument loadDocument(OpenAPI staticModel, OpenAPI annotationMode

private OpenApiDocument storeDocument(OutputTargetBuildItem out,
SmallRyeOpenApiConfig smallRyeOpenApiConfig,
IndexView index,
OpenAPI loadedModel) throws IOException {
return storeDocument(out, smallRyeOpenApiConfig, loadedModel, true);
return storeDocument(out, smallRyeOpenApiConfig, index, loadedModel, true);
}

private OpenApiDocument storeDocument(OutputTargetBuildItem out,
SmallRyeOpenApiConfig smallRyeOpenApiConfig,
IndexView index,
OpenAPI loadedModel,
boolean includeRuntimeFilters) throws IOException {

Config config = ConfigProvider.getConfig();
OpenApiConfig openApiConfig = new OpenApiConfigImpl(config);

OpenApiDocument document = prepareOpenApiDocument(loadedModel, null, Collections.emptyList());
OpenApiDocument document = prepareOpenApiDocument(loadedModel, null, Collections.emptyList(), index);

if (includeRuntimeFilters) {
document.filter(filter(openApiConfig)); // This usually happens at runtime, so when storing we want to filter here too.
document.filter(filter(openApiConfig, index)); // This usually happens at runtime, so when storing we want to filter here too.
}

// By default, also add the auto generated server
Expand All @@ -1112,7 +1114,7 @@ private OpenApiDocument storeDocument(OutputTargetBuildItem out,
} catch (RuntimeException re) {
if (includeRuntimeFilters) {
// This is a Runtime filter, so it might not work at build time. In that case we ignore the filter.
return storeDocument(out, smallRyeOpenApiConfig, loadedModel, false);
return storeDocument(out, smallRyeOpenApiConfig, index, loadedModel, false);
} else {
throw re;
}
Expand All @@ -1131,12 +1133,13 @@ private OpenApiDocument storeDocument(OutputTargetBuildItem out,

private OpenApiDocument prepareOpenApiDocument(OpenAPI staticModel,
OpenAPI annotationModel,
List<AddToOpenAPIDefinitionBuildItem> openAPIBuildItems) {
List<AddToOpenAPIDefinitionBuildItem> openAPIBuildItems,
IndexView index) {
Config config = ConfigProvider.getConfig();
OpenApiConfig openApiConfig = new OpenApiConfigImpl(config);

OpenAPI readerModel = OpenApiProcessor.modelFromReader(openApiConfig,
Thread.currentThread().getContextClassLoader());
Thread.currentThread().getContextClassLoader(), index);

OpenApiDocument document = createDocument(openApiConfig);
if (annotationModel != null) {
Expand All @@ -1158,8 +1161,8 @@ private OpenApiDocument createDocument(OpenApiConfig openApiConfig) {
return document;
}

private OASFilter filter(OpenApiConfig openApiConfig) {
private OASFilter filter(OpenApiConfig openApiConfig, IndexView index) {
return OpenApiProcessor.getFilter(openApiConfig,
Thread.currentThread().getContextClassLoader());
Thread.currentThread().getContextClassLoader(), index);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.openapi.OASFilter;
import org.eclipse.microprofile.openapi.models.OpenAPI;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;

import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.smallrye.openapi.runtime.filter.DisabledRestEndpointsFilter;
Expand All @@ -28,6 +30,7 @@
public class OpenApiDocumentService implements OpenApiDocumentHolder {

private static final String OPENAPI_SERVERS = "mp.openapi.servers";
private static final IndexView EMPTY_INDEX = new Indexer().complete();
private final OpenApiDocumentHolder documentHolder;
private final String previousOpenApiServersSystemPropertyValue;

Expand Down Expand Up @@ -90,7 +93,7 @@ static class StaticDocument implements OpenApiDocumentHolder {
document.filter(autoFilter);
}
document.filter(new DisabledRestEndpointsFilter());
document.filter(OpenApiProcessor.getFilter(openApiConfig, cl));
document.filter(OpenApiProcessor.getFilter(openApiConfig, cl, EMPTY_INDEX));
document.initialize();

this.jsonDocument = OpenApiSerializer.serialize(document.get(), Format.JSON)
Expand Down Expand Up @@ -133,7 +136,7 @@ static class DynamicDocument implements OpenApiDocumentHolder {
if (is != null) {
try (OpenApiStaticFile staticFile = new OpenApiStaticFile(is, Format.JSON)) {
this.openApiConfig = new OpenApiConfigImpl(config);
this.userFilter = OpenApiProcessor.getFilter(openApiConfig, cl);
this.userFilter = OpenApiProcessor.getFilter(openApiConfig, cl, EMPTY_INDEX);
this.autoFilter = autoFilter;
this.generatedOnBuild = OpenApiProcessor.modelFromStaticFile(this.openApiConfig, staticFile);
this.disabledEndpointsFilter = new DisabledRestEndpointsFilter();
Expand Down