GithubHelp home page GithubHelp logo

nuxtswagger's People

Contributors

dependabot[bot] avatar elevista avatar fureweb-com avatar sungwooyangyanolja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nuxtswagger's Issues

Generate error when a 200 response has no content

Hi there, thanks for this handy library. I just found a issue when generating types:

When 200 responses only have description I get the following error

node_modules/nuxtswagger/dist/schema/v3/Template.js:15
        const schema = (_a = content['application/json']) === null || _a === void 0 ? void 0 : _a.schema;
                                    ^

TypeError: Cannot read property 'application/json' of undefined

Can you add support for responses with no return value?

{
  "description": "object created"
}

Set options using nuxt.config baseurl not working

The following code does not seem to set the baseurl. Anybody else has this issue?

 publicRuntimeConfig: {
    nuxtswagger: [
      {
        pluginName: 'api1',
        axiosConfig: { baseURL: process.env.api1},
      },
      {
        pluginName: 'api2',
        axiosConfig: { baseURL: process.env.api2},
      },
}

Improve README

Following the README doesn't work.

npm i -D nuxtswagger
nuxtswagger https://api.server.foo/swagger.json

zsh: command not found: swagger

Later in the README I see we have to add the command to our package.json manually in the script section:

  "scripts": {
     "dev": "nuxt dev",
     "build": "nuxt build",
     "start": "nuxt start",
     "swagger": "nuxtswagger"
  },

But now the instruction are still wrong, we need to do
yarn run swagger https://api.server.foo/swagger.json and not nuxtswagger https://api.server.foo/swagger.json

Configure `requestInterceptor` and `responseInterceptor`

Hi,
How could I define requestInterceptor and responseInterceptor for the plugin ?
I currently use a custom plugin for Swagger and I did like so but it fetch the schema at runtime instead of build time which increase page load time.

import SwaggerClient from 'swagger-client';

export default async ({ app, $config, $auth }, inject) => {
    const swagger = await SwaggerClient({
        url: $config.apiURL,
        async requestInterceptor(request) {
            let jwt = $auth.strategy.token.get();
            if (jwt) {
                if ($auth.strategy.token.status().expired()) {
                    if ($auth.strategy.refreshToken.status().valid()) {
                        // Forcer le reload des tokens
                        await $auth.refreshTokens();
                        jwt = $auth.strategy.token.get();
                    } else {
                        $auth.logout();
                        return;
                    }
                }
                request.headers.Authorization = jwt;
            }
            request.headers['Accept-Language'] = app.i18n.locale;
            request.headers.Accept = 'application/json';
            return request;
        },
        responseInterceptor(response) {
            if (response.status === 401) {
                $auth.logout();
            }
            return response;
        },
    });
    inject('swagger', swagger);
};

Support for OpenAPI and YAML

Currently this plugin only seem to support Swagger schema as JSON, but our project use an OpenAPI YAML schema.
Official swagger-client library also support OpenAPI schema definition in both JSON and YAML format, could it be possible to support this ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.