swagger-typescript-api
swagger-typescript-api copied to clipboard
Feature Request: Basic http authentication support
Knife4j(a swagger doc server) can set up a basic http authentication with username and password which swagger-typescript-api can not fetch api.json without login.
Currently, i solve this problem with the code below
const axios = require('axios');
axios.default.defaults.auth = {
username: 'xxx',
password: 'xxx',
};
generateApi({
name: 'api.ts',
url: 'http://www.example.com/',
templates: path.join(__dirname, '/templates'),
//use axios
httpClientType: 'axios',
})
it will be good if swagger-typescript-api can support this syntax
generateApi({
name: 'api.ts',
url: 'http://www.example.com/',
templates: path.join(__dirname, '/templates'),
//support auth options
auth: {
username: 'xxx',
password: '123',
}
})
npx swagger-typescript-api -p https://www.example.com/v3/api-docs?group=V1.0 -o ./src -n myApi.ts --auth username:password
Instead of doing this we can simply achieve this with the current implementation
add authorizationToken in you generateApi function
use it like this
authorizationToken: `Basic ${btoa(
'username:password'
)}`,