Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagger-axios-codegen

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-axios-codegen - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

10

CHANGELOG.md
## 0.8.1
- Improve request params
- Ignore generated file with tslint and eslint
- Improve generic key [issue45](https://github.com/Manweill/swagger-axios-codegen/issues/45)
- Remove unused import [PR44](https://github.com/Manweill/swagger-axios-codegen/pull/44)
## 0.8.0

@@ -3,0 +13,0 @@

2

dist/requestCodegen/getRequestParameters.d.ts

@@ -11,4 +11,4 @@ import { IParameter } from '../swaggerInterfaces';

queryParameters: string[];
bodyParameters: string[];
bodyParameter: string;
imports: string[];
};

@@ -19,2 +19,3 @@ "use strict";

let imports = [];
let moreBodyParams = params.filter(item => item.in === 'body').length > 1;
params.forEach(p => {

@@ -68,13 +69,15 @@ let propType = '';

else if (p.in === 'body') {
var body = p.schema
? p.schema.type === 'array'
? `[...params['${paramName}']]`
: `...params['${paramName}']`
: `'${p.name}':params['${paramName}']`;
const body = moreBodyParams ? `'${p.name}':params['${paramName}']` : `params['${paramName}']`;
// var body = p.schema
// ? p.schema.type === 'array'
// ? `[...params['${paramName}']]`
// : `...params['${paramName}']`
// : `'${p.name}':params['${paramName}']`
bodyParameters.push(body);
}
});
return { requestParameters, requestFormData, requestPathReplace, queryParameters, bodyParameters, imports };
const bodyParameter = moreBodyParams ? `{${bodyParameters.join(',')}}` : bodyParameters.join(',');
return { requestParameters, requestFormData, requestPathReplace, queryParameters, bodyParameter, imports };
}
exports.getRequestParameters = getRequestParameters;
//# sourceMappingURL=getRequestParameters.js.map

@@ -93,3 +93,3 @@ "use strict";

const { useClassTransformer } = options;
const { queryParameters = [], bodyParameters = [] } = parsedParameters;
const { queryParameters = [], bodyParameter } = parsedParameters;
const nonArrayType = responseType.replace('[', '').replace(']', '');

@@ -111,4 +111,5 @@ const isArrayType = responseType.indexOf('[') > 0;

: ''}
let data = ${parsedParameters && bodyParameters.length > 0
? bodyParameters.length === 1 && bodyParameters[0].startsWith('[') ? bodyParameters[0] : '{' + bodyParameters.join(',') + '}'
let data = ${parsedParameters && bodyParameter.length > 0
// ? bodyParameters.length === 1 && bodyParameters[0].startsWith('[') ? bodyParameters[0] : '{' + bodyParameters.join(',') + '}'
? bodyParameter
: 'null'}

@@ -136,3 +137,5 @@ ${contentType === 'multipart/form-data' ? formData : ''}

return `/** Generate by swagger-axios-codegen */
import axiosStatic, { AxiosPromise, AxiosInstance } from 'axios';
// tslint:disable
/* eslint-disable */
import axiosStatic, { AxiosInstance } from 'axios';

@@ -183,3 +186,4 @@ ${classTransformerImport}

return `/** Generate by swagger-axios-codegen */
// tslint:disable
/* eslint-disable */
export interface IRequestOptions {

@@ -186,0 +190,0 @@ headers?: any;

@@ -17,2 +17,3 @@ import { IDefinitionClass, IDefinitionEnum } from "./baseInterfaces";

export declare function refClassName(s: string): string;
export declare function isBaseType(s: string): boolean;
export declare function toBaseType(s: string, format?: string): string;

@@ -19,0 +20,0 @@ export declare function getMethodName(path: string): string;

@@ -5,3 +5,3 @@ "use strict";

// 是否是接口类型
exports.isGenerics = (s) => /^.+\[.+\]$/.test(s);
exports.isGenerics = (s) => (/^.+\[.+\]$/.test(s) || /^.+\«.+\»$/.test(s));
/**

@@ -29,3 +29,4 @@ * 分解泛型接口

// return `${interfaceClassName}<${toBaseType(TClassName)}>`
return trimString(propType.replace(/[`~!@#$%^&*()_+<>?:"{},.\/;'[\]]/g, '_'), '_', 'right');
const str = trimString(propType.replace(/[`~!@#$%^&*()_+<>«»?:"{},.\/;'[\]]/g, '_'), '_', 'right');
return str;
}

@@ -37,2 +38,6 @@ else {

exports.refClassName = refClassName;
function isBaseType(s) {
return ['boolean', 'number', 'string', 'string', 'Date'].includes(s);
}
exports.isBaseType = isBaseType;
function toBaseType(s, format) {

@@ -39,0 +44,0 @@ if (s === undefined || s === null || s.length === 0) {

{
"name": "swagger-axios-codegen",
"version": "0.8.0",
"version": "0.8.1",
"main": "./dist/index",

@@ -39,2 +39,2 @@ "typings": "./dist/",

}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc