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

Swagger UI 5.4.2 Redoc 2.1.1 #1179

Merged
merged 1 commit into from
Sep 13, 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
Expand All @@ -36,6 +37,7 @@
public abstract class OpenAPIMixin {

@JsonAnyGetter
@JsonInclude
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is @JsonInclude necessary? Do we have any test to verify it is necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdelamo Yeas, it necessary. We don't need to test it. These classes just copied from swagger-core project. This change i got from here: swagger-api/swagger-core#4468

I keep these classes up to date all the time. Why did I copy this piece from swagger-core? For two reasons:

  1. This allowed me to remove a bunch of unnecessary dependencies from the project, i.e. from swagger-core, we used only the jackson settings.

  2. Now there is a possibility to customize logic, due to this we managed to fix a couple of problems in serialization / deserialization.

public abstract Map<String, Object> getExtensions();

@JsonAnySetter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class SwaggerUIConfig extends AbstractViewConfig {
private static final String COMMNA_NEW_LINE = ",\n";

// https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md
private static final Map<String, Function<String, Object>> VALID_OPTIONS = new HashMap<>(29);
private static final Map<String, Function<String, Object>> VALID_OPTIONS = new HashMap<>(30);
// https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/oauth2.md
private static final Map<String, Function<String, Object>> VALID_OAUTH2_OPTIONS = new HashMap<>(9);

Expand Down Expand Up @@ -98,6 +98,7 @@ final class SwaggerUIConfig extends AbstractViewConfig {
VALID_OPTIONS.put("supportedSubmitMethods", AbstractViewConfig::asString);
VALID_OPTIONS.put("validatorUrl", AbstractViewConfig::asQuotedString);
VALID_OPTIONS.put("withCredentials", AbstractViewConfig::asBoolean);
VALID_OPTIONS.put("persistAuthorization", AbstractViewConfig::asBoolean);
sdelamo marked this conversation as resolved.
Show resolved Hide resolved

VALID_OAUTH2_OPTIONS.put(OPTION_OAUTH2 + ".clientId", AbstractViewConfig::asQuotedString);
VALID_OAUTH2_OPTIONS.put(OPTION_OAUTH2 + ".clientSecret", AbstractViewConfig::asQuotedString);
Expand Down
520 changes: 267 additions & 253 deletions openapi/src/main/resources/templates/redoc/res/redoc.standalone.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class OpenApiOperationViewParseSpec extends Specification {

void "test parse OpenApiView specification, swagger-ui enabled"() {
given:
String spec = "swagger-ui.enabled=true,swagger-ui.js.url=version123,swagger-ui.spec.url=/my/spec/file.yml,swagger-ui.theme=flattop,swagger-ui.deepLinking=false"
String spec = "swagger-ui.enabled=true,swagger-ui.js.url=version123,swagger-ui.spec.url=/my/spec/file.yml,swagger-ui.theme=flattop,swagger-ui.deepLinking=false,swagger-ui.persistAuthorization=true"
OpenApiViewConfig cfg = OpenApiViewConfig.fromSpecification(spec, null, new Properties(), null)

expect:
Expand All @@ -73,5 +73,6 @@ class OpenApiOperationViewParseSpec extends Specification {
cfg.swaggerUIConfig.specUrl == "/my/spec/file.yml"
cfg.swaggerUIConfig.theme == SwaggerUIConfig.Theme.FLATTOP
cfg.swaggerUIConfig.options['deepLinking'] == false
cfg.swaggerUIConfig.options['persistAuthorization'] == true
}
}
1 change: 1 addition & 0 deletions src/main/docs/guide/openApiViews/swaggerui.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The views will be generated to the `META-INF/swagger/views/swagger-ui` directory
| `swagger-ui.showExtensions` |
| `swagger-ui.operationsSorter` |
| `swagger-ui.tagsSorter` |
| `swagger-ui.persistAuthorization` |
|===

See https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md[Swagger UI Configuration] for a description.
Expand Down