Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
5 of 6 tasks
roshanjrajan opened this issue Aug 24, 2024 · 1 comment

Comments

@roshanjrajan
Copy link

roshanjrajan commented Aug 24, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants