openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][typescript-fetch] Generated Code missing helpers like numberFromJSONTyped, instanceOfnumber and so forth

Open roshanjrajan opened this issue 1 year ago • 0 comments

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
  1. Copy yaml to test.yaml
  2. Copy json to config.json
  3. Run the command above
  4. Run typescript typechecker or open file and see helper is not found.
Related issues/PRs

Didn't see anything.

Suggest a fix

roshanjrajan avatar Aug 24 '24 06:08 roshanjrajan