mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Added options to handle reserved property names
This commit is contained in:
parent
8368025520
commit
405df66faf
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openapi-typescript-codegen",
|
||||
"version": "0.9.1",
|
||||
"version": "0.9.2",
|
||||
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
|
||||
"author": "Ferdi Koomen",
|
||||
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import camelCase from 'camelcase';
|
||||
|
||||
const reservedWords = /^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
|
||||
/**
|
||||
* Replaces any invalid characters from a parameter name.
|
||||
* For example: 'filter.someProperty' becomes 'filterSomeProperty'.
|
||||
@ -9,5 +11,5 @@ export function getOperationParameterName(value: string): string {
|
||||
.replace(/^[^a-zA-Z]+/g, '')
|
||||
.replace(/[^\w\-]+/g, '-')
|
||||
.trim();
|
||||
return camelCase(clean);
|
||||
return camelCase(clean).replace(reservedWords, '_$1');
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import camelCase from 'camelcase';
|
||||
|
||||
const reservedWords = /^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
|
||||
/**
|
||||
* Replaces any invalid characters from a parameter name.
|
||||
* For example: 'filter.someProperty' becomes 'filterSomeProperty'.
|
||||
@ -9,5 +11,5 @@ export function getOperationParameterName(value: string): string {
|
||||
.replace(/^[^a-zA-Z]+/g, '')
|
||||
.replace(/[^\w\-]+/g, '-')
|
||||
.trim();
|
||||
return camelCase(clean);
|
||||
return camelCase(clean).replace(reservedWords, '_$1');
|
||||
}
|
||||
|
||||
@ -951,6 +951,8 @@ export type ModelWithProperties = {
|
||||
boolean?: boolean;
|
||||
reference?: ModelWithString;
|
||||
'property with space'?: string;
|
||||
default?: string;
|
||||
try?: string;
|
||||
readonly '@namespace.string'?: string;
|
||||
readonly '@namespace.integer'?: number;
|
||||
}
|
||||
@ -1630,6 +1632,12 @@ export const $ModelWithProperties = {
|
||||
'property with space': {
|
||||
type: 'string',
|
||||
},
|
||||
default: {
|
||||
type: 'string',
|
||||
},
|
||||
try: {
|
||||
type: 'string',
|
||||
},
|
||||
'@namespace.string': {
|
||||
type: 'string',
|
||||
isReadOnly: true,
|
||||
@ -2059,6 +2067,7 @@ export class ParametersService {
|
||||
* @param parameterPath1 This is the parameter that goes into the path
|
||||
* @param parameterPath2 This is the parameter that goes into the path
|
||||
* @param parameterPath3 This is the parameter that goes into the path
|
||||
* @param _default This is the parameter with a reserved keyword
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static async callWithWeirdParameterNames(
|
||||
@ -2069,6 +2078,7 @@ export class ParametersService {
|
||||
parameterPath1?: string,
|
||||
parameterPath2?: string,
|
||||
parameterPath3?: string,
|
||||
_default?: string,
|
||||
): Promise<void> {
|
||||
const result = await __request({
|
||||
method: 'GET',
|
||||
@ -3363,6 +3373,8 @@ export type ModelWithProperties = {
|
||||
boolean?: boolean;
|
||||
reference?: ModelWithString;
|
||||
'property with space'?: string;
|
||||
default?: string;
|
||||
try?: string;
|
||||
readonly '@namespace.string'?: string;
|
||||
readonly '@namespace.integer'?: number;
|
||||
}
|
||||
@ -4197,6 +4209,12 @@ export const $ModelWithProperties = {
|
||||
'property with space': {
|
||||
type: 'string',
|
||||
},
|
||||
default: {
|
||||
type: 'string',
|
||||
},
|
||||
try: {
|
||||
type: 'string',
|
||||
},
|
||||
'@namespace.string': {
|
||||
type: 'string',
|
||||
isReadOnly: true,
|
||||
@ -4697,6 +4715,7 @@ export class ParametersService {
|
||||
* @param parameterPath1 This is the parameter that goes into the path
|
||||
* @param parameterPath2 This is the parameter that goes into the path
|
||||
* @param parameterPath3 This is the parameter that goes into the path
|
||||
* @param _default This is the parameter with a reserved keyword
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static async callWithWeirdParameterNames(
|
||||
@ -4708,6 +4727,7 @@ export class ParametersService {
|
||||
parameterPath1?: string,
|
||||
parameterPath2?: string,
|
||||
parameterPath3?: string,
|
||||
_default?: string,
|
||||
): Promise<void> {
|
||||
const result = await __request({
|
||||
method: 'GET',
|
||||
|
||||
@ -133,6 +133,13 @@
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter with a reserved keyword",
|
||||
"name": "default",
|
||||
"in": "path",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter that goes into the request header",
|
||||
"name": "parameter.header",
|
||||
@ -1141,6 +1148,12 @@
|
||||
"property with space": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": {
|
||||
"type": "string"
|
||||
},
|
||||
"try": {
|
||||
"type": "string"
|
||||
},
|
||||
"@namespace.string": {
|
||||
"type": "string",
|
||||
"readOnly": true
|
||||
|
||||
@ -173,6 +173,16 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter with a reserved keyword",
|
||||
"name": "default",
|
||||
"in": "path",
|
||||
"required": false,
|
||||
"nullable": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter that goes into the request header",
|
||||
"name": "parameter.header",
|
||||
@ -1804,6 +1814,12 @@
|
||||
"property with space": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": {
|
||||
"type": "string"
|
||||
},
|
||||
"try": {
|
||||
"type": "string"
|
||||
},
|
||||
"@namespace.string": {
|
||||
"type": "string",
|
||||
"readOnly": true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user