chenweiqun / swagger-vue Goto Github PK
View Code? Open in Web Editor NEWSwagger to JS & Vue & Axios Codegen
License: MIT License
Swagger to JS & Vue & Axios Codegen
License: MIT License
is invalid for option "encoding"
对中文生成API过敏,提示:对选项“encoding”无效
The module works well for OAS 2 but not with OAS 3.
Are there any upcoming releases or is it an issue from my side?
Thanks!
/Users/nagnath.masali/Swagger/For Vue/node_modules/swagger-vue-axios/node_modules/swagger-vue/lib/parse.js:152
swagger.apis.forEach(function (api) {
^
TypeError: Cannot read property 'forEach' of undefined
at getViewForSwagger1 (/Users/nagnath.masali/Swagger/For Vue/node_modules/swagger-vue-axios/node_modules/swagger-vue/lib/parse.js:152:16)
at parse (/Users/nagnath.masali/Swagger/For Vue/node_modules/swagger-vue-axios/node_modules/swagger-vue/lib/parse.js:206:74)
at module.exports (/Users/nagnath.masali/Swagger/For Vue/node_modules/swagger-vue-axios/node_modules/swagger-vue/index.js:4:14)
at Object.<anonymous> (/Users/nagnath.masali/Swagger/For Vue/node_modules/swagger-vue-axios/node_modules/swagger-vue/example/create_api/index.js:10:20)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
Hi chenweiqun!
I am trying to pass a configuration to axios to send credentials in a cross-site call. I've tried (by looking at the source code) this, but it doesn't work. I'm doing something wrong? I've also tried other axios parameters without success.
shopDeleteById({ id: shop.id, $config: { withCredentials: true } }).then(() => {
Thanks a lot! :)
Hi, I have an axios instance with request interceptors.
How can I set my axios instance?
import axios from 'axios'
let axios
function setAxios (vueAxios) {
axios = vueAxios
}
function getAxios () {
return axios
}
export { getAxios }
export default setAxios
import { getAxios } from '../../index'
export default {
getAlms () {
return getAxios().get(pathAlms).then(response => {
return response.data
})
}
}
Is it possible to generate models similar to the swagger-codegen for javascript?
Hello chenweiqun,
I found this project when I was searching someway of integrating an swagger api to vue. I'm able with your code, to generate the api.js code, but I have no idea how to integrate that into vue.
Can you explain briefly how to do it? (How to use the generated file)
Thanks!
你好,是否可以提供详细教程,谢谢!
I add two lines (19,20) in generated code for work with cookies.
config = config || {};
config.withCredentials = true;
but when i use GET requests, cookie not send to server, but with POST all OK.
P.S. Post request generate another OPTIONS request.
this YAML
/thread/settings_sources_keywords:
post:
tags:
- thread
summary: ThreadSetSourcesKeywords
description: ThreadSetSourcesKeywords
operationId: ThreadSetSourcesKeywords
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Thread settings - keywords
required: true
schema:
$ref: '#/definitions/ThreadKeywords'
responses:
'200':
description: Thread settings, set keywords
'403':
description: Access denied
'405':
description: Invalid input
generated this code
/**
* ThreadGetSourcesKeywords
* request: ThreadGetSourcesKeywords
* url: ThreadGetSourcesKeywordsURL
* method: ThreadGetSourcesKeywords_TYPE
* raw_url: ThreadGetSourcesKeywords_RAW_URL
* @param threadId - thread id
*/
export const ThreadGetSourcesKeywords = function(parameters = {}) {
const domain = parameters.$domain ? parameters.$domain : getDomain()
const config = parameters.$config
let path = '/thread/settings_sources_keywords_get'
let body
let queryParameters = {}
let form = {}
if (parameters['threadId'] !== undefined) {
body = parameters['threadId']
}
if (parameters['threadId'] === undefined) {
return Promise.reject(new Error('Missing required parameter: threadId'))
}
if (parameters.$queryParameters) {
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
});
}
return request('post', domain + path, body, queryParameters, form, config)
}
export const ThreadGetSourcesKeywords_RAW_URL = function() {
return '/thread/settings_sources_keywords_get'
}
export const ThreadGetSourcesKeywords_TYPE = function() {
return 'post'
}
BUT
this
/thread/settings_periods_get:
post:
tags:
- thread
summary: ThreadGetPeriods
description: Get thread periods
operationId: ThreadGetPeriods
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
required: true
description: thread id
schema:
$ref: '#/definitions/ThreadId'
responses:
'200':
description: Thread settings, get time periods
schema:
$ref: '#/definitions/ThreadSettingsPeriods'
'403':
description: Access denied
'405':
description: Invalid input
generated this code
/**
* Get thread periods
* request: ThreadGetPeriods
* url: ThreadGetPeriodsURL
* method: ThreadGetPeriods_TYPE
* raw_url: ThreadGetPeriods_RAW_URL
* @param body - thread id
*/
export const ThreadGetPeriods = function(parameters = {}) {
const domain = parameters.$domain ? parameters.$domain : getDomain()
const config = parameters.$config
let path = '/thread/settings_periods_get'
let body
let queryParameters = {}
let form = {}
if (parameters['body'] !== undefined) {
body = parameters['body']
}
if (parameters['body'] === undefined) {
return Promise.reject(new Error('Missing required parameter: body'))
}
if (parameters.$queryParameters) {
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
});
}
return request('post', domain + path, body, queryParameters, form, config)
}
schemes
ThreadId:
type: object
required:
- thread_id
properties:
thread_id:
type: string
description: thread_id
ThreadKeywords:
type: object
required:
- thread_id
- keywords
- stopkeywords
properties:
thread_id:
type: string
keywords:
type: array
items:
type: string
stopkeywords:
type: array
items:
type: string
My API contain this route path /*
. When I execute swagger-vue, it throw an error here (toUpperCase on undefined):
Line 25 in 689037b
I suggest adding path === '/*'
to line 10.
Hi!
Our SAST shows us the following error caused by handlebars:
"A prototype pollution vulnerability in handlebars may lead to remote code execution if an attacker can control the template in handlebars"
please publish on npm :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.