Skip to content

Commit

Permalink
expose Swagger configuration tryItOutEnabled property (#1606)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolellis authored Oct 9, 2023
1 parent 5e93199 commit ef2f847
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ private static void addUrlSection(Map<String, String> urls, String urlsPrimaryNa
DEFAULT_OPTIONS.put(Option.onComplete, null);
DEFAULT_OPTIONS.put(Option.syntaxHighlight, null);
DEFAULT_OPTIONS.put(Option.queryConfigEnabled, null);
DEFAULT_OPTIONS.put(Option.tryItOutEnabled, null);

// Network section
DEFAULT_OPTIONS.put(Option.oauth2RedirectUrl, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public enum Option {
layout,
plugins,
presets,
tryItOutEnabled,
// OAuth related
initOAuthSection,
oauthClientId,
Expand Down
1 change: 1 addition & 0 deletions ui/open-api-ui/src/main/resources/template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
tagsSorter: ${tagsSorter},
onComplete: ${onComplete},
syntaxHighlight: ${syntaxHighlight},
tryItOutEnabled: ${tryItOutEnabled},
requestInterceptor: ${requestInterceptor},
request.curlOptions: ${requestCurlOptions},
responseInterceptor: ${responseInterceptor},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void testCreateDefault() throws IOException {
assertTrue(s.contains("dom_id: '#swagger-ui',"));
assertTrue(s.contains("deepLinking: true,"));
assertFalse(s.contains("queryConfigEnabled"));

assertFalse(s.contains("tryItOutEnabled"));
}

@Test
Expand Down Expand Up @@ -240,4 +240,17 @@ void testCreateWithSyntaxHighlightObject() throws IOException {

assertTrue(s.contains("syntaxHighlight: { activated: true, theme: \"monokai\" },"));
}

@Test
void testCreateWithTryItOutEnabledBoolean() throws IOException {
Map<Option, String> options = new HashMap<>();
options.put(Option.tryItOutEnabled, "true");

byte[] indexHtml = IndexHtmlCreator.createIndexHtml(options);
assertNotNull(indexHtml);

String s = new String(indexHtml);

assertTrue(s.contains("tryItOutEnabled: true,"));
}
}

0 comments on commit ef2f847

Please sign in to comment.