Description
I'm generating a typescript-fetch client using OpenAPI Generator 4.0.0-beta. After running the generator, the following functions are included in the output, but they are not defined:
Also, the type for the property is any, but it should be object I think?
openapi-generator version
4.0.0-beta
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: MyAPI
description: MY API
version: 0.0.0
servers:
- url: http://localhost:8080/api/
paths:
/example:
get:
operationId: getExample
responses:
"200":
description: "Success"
content:
application/json:
schema:
$ref: "#/components/schemas/Example"
components:
schemas:
Example:
required:
- data
properties:
data:
type: object
Command line used for generation
$ node_modules/.bin/openapi-generator generate -i openapi.yaml -o src -g typescript-fetch
Steps to reproduce
I've created a gist that should help to reproduce the issue.
$ git clone https://gist.github.com/rzane/724ad1ed08721d04966f121461c0737d bug-report
$ cd bug-report
$ npm install
$ npm run generate
$ npm run test
You should see the following output:
> tsc -p src --noEmit
src/models/Example.ts:31:17 - error TS2304: Cannot find name 'anyFromJSON'.
31 'data': anyFromJSON(json['data']),
~~~~~~~~~~~
src/models/Example.ts:40:17 - error TS2304: Cannot find name 'anyToJSON'.
40 'data': anyToJSON(value.data),
~~~~~~~~~
The source of the error can be found in src/models/Example.ts, which contains the following:
export interface Example {
/**
*
* @type {any}
* @memberof Example
*/
data: any;
}
export function ExampleFromJSON(json: any): Example {
return {
'data': anyFromJSON(json['data']),
};
}
export function ExampleToJSON(value?: Example): any {
if (value === undefined) {
return undefined;
}
return {
'data': anyToJSON(value.data),
};
}
Related issues/PRs
I couldn't find one 🤷♂️
Suggest a fix
Ideally, the property data would be declared as object or empty interface ExampleItems, rather than any.
More importantly, if the schema is an object without any properties or additionalProperties, there should be no coercion.
Description
I'm generating a
typescript-fetchclient using OpenAPI Generator 4.0.0-beta. After running the generator, the following functions are included in the output, but they are not defined:anyFromJSONanyToJSONAlso, the type for the property is
any, but it should beobjectI think?openapi-generator version
4.0.0-beta
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
I've created a gist that should help to reproduce the issue.
You should see the following output:
The source of the error can be found in
src/models/Example.ts, which contains the following:Related issues/PRs
I couldn't find one 🤷♂️
Suggest a fix
Ideally, the property
datawould be declared asobjector empty interfaceExampleItems, rather thanany.More importantly, if the schema is an object without any
propertiesoradditionalProperties, there should be no coercion.