mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Fixed minor issue with boolean enums
This commit is contained in:
parent
5a13939d5e
commit
872ef7c6f4
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openapi-typescript-codegen",
|
||||
"version": "0.7.2",
|
||||
"version": "0.8.0",
|
||||
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
|
||||
"author": "Ferdi Koomen",
|
||||
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",
|
||||
|
||||
@ -978,6 +978,13 @@
|
||||
"Order": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"bool": {
|
||||
"description": "Simple boolean enum",
|
||||
"type": "boolean",
|
||||
"enum": [
|
||||
true
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
|
||||
@ -18,7 +18,7 @@ export function getEnum(values?: (string | number)[]): Enum[] {
|
||||
};
|
||||
}
|
||||
return {
|
||||
name: value
|
||||
name: String(value)
|
||||
.replace(/\W+/g, '_')
|
||||
.replace(/^(\d+)/g, '_$1')
|
||||
.replace(/([a-z])([A-Z]+)/g, '$1_$2')
|
||||
|
||||
@ -53,7 +53,7 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isDefiniti
|
||||
return model;
|
||||
}
|
||||
|
||||
if (definition.enum) {
|
||||
if (definition.enum && definition.type !== 'boolean') {
|
||||
const enumerators = getEnum(definition.enum);
|
||||
const extendedEnumerators = extendEnum(enumerators, definition);
|
||||
if (extendedEnumerators.length) {
|
||||
|
||||
@ -18,7 +18,7 @@ export function getEnum(values?: (string | number)[]): Enum[] {
|
||||
};
|
||||
}
|
||||
return {
|
||||
name: value
|
||||
name: String(value)
|
||||
.replace(/\W+/g, '_')
|
||||
.replace(/^(\d+)/g, '_$1')
|
||||
.replace(/([a-z])([A-Z]+)/g, '$1_$2')
|
||||
|
||||
@ -55,7 +55,7 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isDefiniti
|
||||
return model;
|
||||
}
|
||||
|
||||
if (definition.enum) {
|
||||
if (definition.enum && definition.type !== 'boolean') {
|
||||
const enumerators = getEnum(definition.enum);
|
||||
const extendedEnumerators = extendEnum(enumerators, definition);
|
||||
if (extendedEnumerators.length) {
|
||||
|
||||
@ -490,6 +490,71 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v{api-version}/collectionFormat": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"CollectionFormat"
|
||||
],
|
||||
"operationId": "CollectionFormat",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "This is an array parameter that is send as csv format (comma-separated values)",
|
||||
"name": "parameterArrayCSV",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "csv"
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter that is send as ssv format (space-separated values)",
|
||||
"name": "parameterArraySSV",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "ssv"
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter that is send as tsv format (tab-separated values)",
|
||||
"name": "parameterArrayTSV",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "tsv"
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter that is send as pipes format (pipe-separated values)",
|
||||
"name": "parameterArrayMulti",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "pipes"
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter that is send as multi format (multiple parameter instances)",
|
||||
"name": "parameterArrayMulti",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "multi"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v{api-version}/types": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@ -932,6 +997,13 @@
|
||||
"500 foo.bar",
|
||||
"600 foo&bar"
|
||||
]
|
||||
},
|
||||
"bool": {
|
||||
"description": "Simple boolean enum",
|
||||
"type": "boolean",
|
||||
"enum": [
|
||||
true
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -712,6 +712,86 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v{api-version}/collectionFormat": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"CollectionFormat"
|
||||
],
|
||||
"operationId": "CollectionFormat",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "This is an array parameter that is send as csv format (comma-separated values)",
|
||||
"name": "parameterArrayCSV",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"collectionFormat": "csv"
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter that is send as ssv format (space-separated values)",
|
||||
"name": "parameterArraySSV",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"collectionFormat": "ssv"
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter that is send as tsv format (tab-separated values)",
|
||||
"name": "parameterArrayTSV",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"collectionFormat": "tsv"
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter that is send as pipes format (pipe-separated values)",
|
||||
"name": "parameterArrayMulti",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"collectionFormat": "pipes"
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter that is send as multi format (multiple parameter instances)",
|
||||
"name": "parameterArrayMulti",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"collectionFormat": "multi"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v{api-version}/types": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@ -1390,6 +1470,13 @@
|
||||
"500 foo.bar",
|
||||
"600 foo&bar"
|
||||
]
|
||||
},
|
||||
"bool": {
|
||||
"description": "Simple boolean enum",
|
||||
"type": "boolean",
|
||||
"enum": [
|
||||
true
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user