8000 Add support for OpenAPI and Swagger UI by Hronom · Pull Request #25925 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.keycloak.config;

public class OpenapiOptions {

public static final Option OPENAPI_ENABLE = new OptionBuilder<>("openapi-enable", Boolean.class)
.category(OptionCategory.OPENAPI)
.description("Enable the openapi endpoint.")
.defaultValue(false)
.buildTime(true)
.build();

public static final Option OPENAPI_SWAGGER_UI_ENABLE = new OptionBuilder<>("openapi-swagger-ui-enable", Boolean.class)
.category(OptionCategory.OPENAPI)
.description("Enable Swagger UI endpoint.")
.defaultValue(false)
.buildTime(true)
.build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum OptionCategory {
SECURITY("Security", 120, ConfigSupportLevel.SUPPORTED),
EXPORT("Export", 130, ConfigSupportLevel.SUPPORTED),
IMPORT("Import", 140, ConfigSupportLevel.SUPPORTED),
OPENAPI("OpenAPI", 150, ConfigSupportLevel.SUPPORTED),
GENERAL("General", 999, ConfigSupportLevel.SUPPORTED);

private final String heading;
Expand Down
4 changes: 4 additions & 0 deletions quarkus/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi-deployment</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
Expand Down
4 changes: 4 additions & 0 deletions quarkus/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>

<!-- SmallRye -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.keycloak.quarkus.runtime.configuration.mappers;

import org.keycloak.config.OpenapiOptions;

import static org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper.fromOption;

final class OpenapiPropertyMappers {

private OpenapiPropertyMappers(){}

public static PropertyMapper[] getOpenapiPropertyMappers() {
return new PropertyMapper[] {
fromOption(OpenapiOptions.OPENAPI_ENABLE)
.to("quarkus.smallrye-openapi.enable")
.paramLabel("openapi")
.build(),
fromOption(OpenapiOptions.OPENAPI_SWAGGER_UI_ENABLE)
.to("quarkus.swag 8000 ger-ui.enable")
.paramLabel("swagger-ui")
.build()
};
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private PropertyMappers(){}
MAPPERS.addAll(ExportPropertyMappers.getMappers());
MAPPERS.addAll(ImportPropertyMappers.getMappers());
MAPPERS.addAll(TruststorePropertyMappers.getMappers());
MAPPERS.addAll(OpenapiPropertyMappers.getOpenapiPropertyMappers());
}

public static ConfigValue getValue(ConfigSourceInterceptorContext context, String name) {
Expand Down
14 changes: 13 additions & 1 deletion quarkus/runtime/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,16 @@ quarkus.transaction-manager.object-store.directory=${kc.home.dir:default}${file.
quarkus.http.limits.max-form-attribute-size=32768

# Configure the content-types that should be recognized as file parts when processing multipart form requests
quarkus.http.body.multipart.file-content-types=application/octet-stream
quarkus.http.body.multipart.file-content-types=application/octet-stream

# Enable/Disable the openapi endpoint
quarkus.smallrye-openapi.enable=false

# Disable validation url
quarkus.swagger-ui.validator-url=none

# Include by default swagger ui in all modes
quarkus.swagger-ui.always-include=true

# Enable/Disable enabling of swagger ui endpoint
quarkus.swagger-ui.enable=false
0