How to use the swagger-ui function in swagger-ui

To help you get started, we’ve selected a few swagger-ui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github swagger-api / swagger-editor / test / unit / plugins / editor / spec.js View on Github external
it("should add a parameter - origin - to state", function() {
      // Given
      const system = SwaggerUi({plugins: [EditorSpecPlugin]})

      // When
      system.specActions.updateSpec("one: 1", "editor")

      // Then
      const res = system.specSelectors.specOrigin()
      expect(res).toEqual("editor")
    })
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.store.feature / src / main / resources / store / source / src / app / components / Apis / Details / ApiConsole.js View on Github external
response => {
                console.info(response);
                let url = response.url;
                const swaggerUI = SwaggerUI({
                    dom_id: "#ui",
                    url: response.url,
                    requestInterceptor: (req) => {
                        // Only set Authorization header if the request matches the spec URL
                        if (req.url === url) {
                          req.headers.Authorization =  "Bearer " + AuthManager.getUser().getPartialToken();
                        }
                        return req;
                      },
                    presets: [
                            SwaggerUI.presets.apis,
                            disableAuthorizeAndInfoPlugin
                    ],
                    plugins: [
                        SwaggerUI.plugins.DownloadUrl
                    ]
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.store.feature / src / main / resources / store-new / source / src / app / components / Apis / Details / ApiConsole / ApiConsole.jsx View on Github external
.then((responses) => {
                const swagger = responses[0];
                const url = swagger.url;
                this.setState({ setSwagger: true });

                const swaggerUI = SwaggerUI({
                    dom_id: '#ui',
                    url: swagger.url,
                    requestInterceptor: (req) => {
                        // Only set Authorization header if the request matches the spec URL
                        if (req.url === url) {
                            req.headers.Authorization = 'Bearer ' + AuthManager.getUser().getPartialToken();
                        }
                        return req;
                    },
                    presets: [SwaggerUI.presets.apis, disableAuthorizeAndInfoPlugin],
                    plugins: [SwaggerUI.plugins.DownloadUrl],
                });
            })
            .catch((error) => {
github apinf / openapi-designer / src / app.js View on Github external
setTimeout(() => {
      this.richPreview = new SwaggerUIBundle({
        spec: this.getFormData(),
        dom_id: '#rich-preview',
        // Disable Swagger.io online validation (AKA spyware)
        validatorUrl: null,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl
        ],
        layout: 'StandaloneLayout'
      });
    }, 0);
  }
github swagger-api / swagger-editor / test / unit / plugins / validate-semantic / validate-helper.js View on Github external
return new Promise((resolve) => {
    const system = SwaggerUi({
      spec,
      domNode: null,
      presets: [
        SwaggerUi.plugins.SpecIndex,
        SwaggerUi.plugins.ErrIndex,
        SwaggerUi.plugins.DownloadUrl,
        SwaggerUi.plugins.SwaggerJsIndex,
        SwaggerUi.plugins.Oas3Index
      ],
      initialState: {
        layout: undefined
      },
      plugins: [
        ASTPlugin,
        ValidateBasePlugin,
        ValidateSemanticPlugin,
github swagger-api / swagger-editor / test / unit / standalone / topbar-insert / index.js View on Github external
return new Promise((resolve) => {
    const system = SwaggerUi({
      spec,
      domNode: null,
      presets: [
        SwaggerUi.plugins.SpecIndex,
        SwaggerUi.plugins.ErrIndex,
        SwaggerUi.plugins.DownloadUrl,
        SwaggerUi.plugins.SwaggerJsIndex,
      ],
      initialState: {
        layout: undefined
      },
      plugins: [
        insertPlugin,
        () => ({
          statePlugins: {
            spec: {
github kvdi / kvdi / ui / app / src / pages / APIExplorer.vue View on Github external
this.$nextTick().then(() => {
      this.ui = SwaggerUIBundle({
        url: '/swagger.json',
        dom_id: '#swagger-ui',
        deepLinking: false,
        displayRequestDuration: true,
        responseInterceptor: (response) => {
          if (response.status === 401) {
            return this.$userStore.dispatch('refreshToken')
              .then(() => {
                response.text = '{"internal": "KVDI: Your access token has been refreshed, please try again"}'
                response.ok = true
                return response
              })
              .catch((err) => {
                console.error(err)
                response.text = `{"internal": "KVDI: Failure while trying to refresh access token: ${err}"}`
                return response
github swagger-api / swagger-editor / src / index.js View on Github external
export default function SwaggerEditor(options) {
  let mergedOptions = deepMerge(defaults, options)

  mergedOptions.presets = defaults.presets.concat(options.presets || [])
  mergedOptions.plugins = defaults.plugins.concat(options.plugins || [])
  return SwaggerUI(mergedOptions)
}
github awslabs / aws-api-gateway-developer-portal / dev-portal / src / pages / Apis.jsx View on Github external
.then(api => {
        if (api) {
          let swaggerUiConfig = {
            dom_id: '#swagger-ui-container',
            plugins: [SwaggerLayoutPlugin],
            supportedSubmitMethods: [],
            spec: api.swagger,
            onComplete: () => {
              if (store.apiKey)
                uiHandler.preauthorizeApiKey("api_key", store.apiKey)
            }
          }
          if (isAuthenticated()) {
            delete swaggerUiConfig.supportedSubmitMethods
          }
          let uiHandler = SwaggerUI(swaggerUiConfig)
        }
      })
  }
github ovh / lhasa / webui / src / app / components / openapi-ui / openapi-ui.component.ts View on Github external
apply() {
    if (!this._url || !this.targetdiv) {
      return;
    }
    SwaggerUI({
      url: this._url,
      domNode: this.targetdiv.nativeElement,
      deepLinking: false,
      validatorUrl: null,
      displayRequestDuration: true,
      presets: [
        SwaggerUI.presets.apis
      ],
    });
  }
}

swagger-ui

[![NPM version](https://badge.fury.io/js/swagger-ui.svg)](http://badge.fury.io/js/swagger-ui) [![Build Status](https://jenkins.swagger.io/view/OSS%20-%20JavaScript/job/oss-swagger-ui-master/badge/icon?subject=jenkins%20build)](https://jenkins.swagger.io/v

Apache-2.0
Latest version published 3 days ago

Package Health Score

83 / 100
Full package analysis