You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/asciidoc/faq.adoc
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -936,3 +936,64 @@ More precisely, this the exhaustive list of spring-boot versions against which `
936
936
|`2.0.x`, `1.5.x` | `1.0.0`+
937
937
938
938
|===
939
+
940
+
=== Customizing swagger static resources
941
+
942
+
You can customize swagger documentation static resources located in `META-INF/resources/webjars/swagger-ui/{swagger.version}/`. The list of resources includes:
943
+
944
+
- `index.html`
945
+
- `swagger-ui-bundle.js`
946
+
- `swagger-ui.css`
947
+
- `swagger-ui-standalone-preset.js`
948
+
- `swagger-ui.css.map`
949
+
- `swagger-ui-bundle.js.map`
950
+
- `swagger-ui-standalone-preset.js.map`
951
+
- `favicon-32x32.png`
952
+
953
+
To do this, you need to extend the implementation of `SwaggerIndexPageTransformer`
954
+
955
+
[source,java]
956
+
----
957
+
public class SwaggerCodeBlockTransformer
958
+
extends SwaggerIndexPageTransformer {
959
+
// < constructor >
960
+
@Override
961
+
public Resource transform(HttpServletRequest request,
962
+
Resource resource,
963
+
ResourceTransformerChain transformer)
964
+
throws IOException {
965
+
if (resource.toString().contains("swagger-ui.css")) {
966
+
final InputStream is = resource.getInputStream();
967
+
final InputStreamReader isr = new InputStreamReader(is);
968
+
try (BufferedReader br = new BufferedReader(isr)) {
969
+
final String css = br.lines().collect(Collectors.joining());
970
+
final byte[] transformedContent = css.replace("old", "new").getBytes();
971
+
return new TransformedResource(resource, transformedContent);
0 commit comments