Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/microfocus/swagger-ui
https://microfocus.github.io/swagger-ui/
https://github.com/microfocus/swagger-ui
openapi rest swagger-ui
Last synced: 6 days ago
JSON representation
https://microfocus.github.io/swagger-ui/
- Host: GitHub
- URL: https://github.com/microfocus/swagger-ui
- Owner: MicroFocus
- License: apache-2.0
- Created: 2020-03-14T00:19:18.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-20T14:35:06.000Z (about 1 year ago)
- Last Synced: 2024-04-13T23:03:38.464Z (9 months ago)
- Topics: openapi, rest, swagger-ui
- Language: HTML
- Homepage:
- Size: 4.51 MB
- Stars: 4
- Watchers: 13
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Open Text Swagger UI
This project is an Open Text branded version of the [Swagger UI](https://github.com/swagger-api/swagger-ui).
## Usage
It can be used from another Java project by including the following dependency:
```xml
com.microfocus.webjars
swagger-ui-dist```
To override swagger configuration params include a **opentext-config.js** file, similar to the one [here](./src/main/resources/opentext-config.js):
Swagger configuration params that can be set in opentext-config.js:
- url: "api-docs/swagger.yaml"
- dom_id: "#swagger-ui
- operationsSorter: "alpha"
- tagsSorter: "alpha"
- docExpansion: "none"
- defaultModelsExpandDepth: -1
- deepLinking: trueFor a complete list of swagger configuration params refer [Swagger configuration params](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#core).
## Using this module in Spring Boot
1. Add the module as a `runtime` dependency.
2. Include a resource file called **opentext-config.js** with the swagger configuration overrides, similar to the one [here](./src/main/resources/opentext-config.js).
Make sure to overide the "url" param to point to your swagger contract.
3. To facilitate [serving static resources](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.html) in Spring Boot override the `addResourceHandlers` function in```java
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {// Configure the external-facing URI path by adding a resource handler
final ResourceHandlerRegistration resourceHandlerRegistration = registry.addResourceHandler("/swagger/**");// Map that external-facing URI path internally to the physical path where the resources are actually located
resourceHandlerRegistration.addResourceLocations(
"classpath:/swagger/",
swaggerContractPath,
"classpath:/META-INF/resources/webjars/opentext-swagger-ui-dist/2.0.0/");final ResourceChainRegistration resourceChainRegistration = resourceRegistration.resourceChain(true);
resourceChainRegistration.addResolver(new PathResourceResolver());
}
```## Using this module in Dropwizard
1. Add the module as a `runtime` dependency.
2. Include a resource file called **swagger-ui-config.js** to override the swagger configuration, similar to the one [here](./src/main/resources/opentext-config.js).
Make sure to overide the "url" param to point to your swagger contract.
3. To facilitate serving static resources in Dropwizard add [AssetBundles](https://www.dropwizard.io/en/latest/manual/core.html#bundles)```java
@Override
public void initialize(Bootstrap bootstrap) {
bootstrap.addBundle(new AssetsBundle(
"/META-INF/resources/webjars/opentext-swagger-ui-dist/2.0.0/", "/swagger/", "index.html", "swagger-ui"));
bootstrap.addBundle(new AssetsBundle(
"/swagger-ui-config.js", "/swagger/opentext-config.js", null, "swagger-ui-config"));super.initialize(bootstrap);
}
```## Using this module in Tomcat
1. Include a resource file called **opentext-config.js** with the swagger configuration overrides, similar to the one [here](./src/main/resources/opentext-config.js).
Make sure to overide the "url" param to point to your swagger contract.
2. Repackage the swagger assets into the war file to be deployed in Tomcat.**Unpack the swagger-ui artifact excluding the default configuration file**
```xmlorg.apache.maven.plugins
maven-dependency-plugin
unpack
com.github.microfocus
swagger-ui-dist
1.0.0
${project.build.directory}/swagger-ui
META-INF/resources/webjars/opentext-swagger-ui-dist/2.0.0/opentext-config.js
```
**Package the war file with the swagger-ui assets and the swagger-ui configuration overide file**
```xmlorg.apache.maven.plugins
maven-war-plugin
false
${project.build.directory}/swagger-ui/META-INF/resources/webjars/opentext-swagger-ui-dist/2.0.0
.
src/main/html
.
${project.build.directory}/swagger-contract/com/hpe/darwin/tag/service/contract
api-docs
```
## Using as an NPM package
This module, `opentext-swagger-ui-dist`, is a dependency-free module that includes everything required to serve OpenText-branded Swagger UI in a server-side project, or a single-page application that can't resolve npm module dependencies.npm install git+ssh://[email protected]/MicroFocus/swagger-ui.git#v2.0.0-dist
Or alternatively if you prefer not to use a **git** url:
npm install https://github.com/MicroFocus/swagger-ui/archive/v2.0.0-dist.tar.gz