openapi-generator
openapi-generator copied to clipboard
[BUG][typescript-fetch] Generated Code missing helpers like numberFromJSONTyped, instanceOfnumber and so forth
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [x] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating the openapi code, it is failing to generate helpers (instanceOfnumber, instanceOfstring, numberFromJSONTyped, stringFromJSONTyped). It fails type checking as a result.
if (instanceOfnumber(json)) {
return numberFromJSONTyped(json, true);
}
if (instanceOfstring(json)) {
return stringFromJSONTyped(json, true);
}
openapi-generator version
On Macos M3 Sonoma using brew
openapi-generator --version
openapi-generator-cli 7.8.0
commit : 6bdc452
built : -999999999-01-01T00:00:00+18:00
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Test
version: 1.0.22
paths: {}
components:
schemas:
Test1:
type: object
properties:
test_type:
type: string
enum:
- FOO
test_value:
oneOf:
- type: integer
required:
- test_type
- test_value
Test2:
description: test
type: object
properties:
something:
type: array
items:
oneOf:
- type: string
- type: integer
required:
- something
Config.json
{
"generateSourceCodeOnly": true
}
Generation Details
openapi-generator generate -i test.yaml -g typescript-fetch -c config.json --global-property models,modelTests=false --additional-properties enumPropertyNaming=UPPERCASE,removeEnumValuePrefix=false
Steps to reproduce
- Copy yaml to
test.yaml - Copy json to
config.json - Run the command above
- Run typescript typechecker or open file and see helper is not found.
Related issues/PRs
Didn't see anything.