Skip to content
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

[BUG] [typescript-angular] Upgrade from 3.3.4 to 4.1.2 breaks any type functionality. #4200

Closed
RaduFurnea opened this issue Oct 21, 2019 · 4 comments

Comments

@RaduFurnea
Copy link

Description

Upgrading code generator from 3.3.4 to 4.1.2 doesn't allow for any as a type.
This functionality seems to be broken since this PR: #2453

While I understand the need for this change, it is an inconsistency in some environments, take for example a server in Spring, where Object can be anything but a primitive, and a client in TypeScript where object can only be { }, and not a string of number.

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Test
  description: Test
  version: 0.0.0
servers:
  - url: http://localhost:8080/api/
paths:
  /example:
    post:
      operationId: filter example
      requestBody:
        description: One filter item
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FilterDTO'  
      responses:
        "200":
          description: "Success"

components:
  schemas:
    FilterDTO:
      properties:
        attribute:
          type: string
        value:
          type: object
Command line used for generation

npx openapi-generator generate -i spec.yml -g typescript-angular -o output

Steps to reproduce

Generate the code, and observe how value is of type object and not any.
I was using this in order to be able to pass any value to this field.

Related issues/PRs

#2453

Suggest a fix

What I suggest is to offer an option to generate a property of type any, maybe using a config option allowAny = true or something similar.

@auto-labeler
Copy link

auto-labeler bot commented Oct 21, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@wing328
Copy link
Member

wing328 commented Oct 21, 2019

What about using --type-mappings to map "object" back to "any"?

e.g. --type-mappings object=any

@RaduFurnea
Copy link
Author

RaduFurnea commented Oct 21, 2019

Hi @wing328, thanks a lot for the quick reply, it seems to do the trick for me. Is this documented somewhere for future reference?

@wing328
Copy link
Member

wing328 commented Oct 21, 2019

Please refer to https://openapi-generator.tech/docs/usage or the project's readme.

@wing328 wing328 closed this as completed Oct 21, 2019
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