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

[typescript] fix: allow 'additionalProperties: true' at top level #16526

Conversation

tcrasset
Copy link
Contributor

@tcrasset tcrasset commented Sep 6, 2023

I was getting the following error

Exception in thread "main" java.lang.RuntimeException: Could not process model 'AvatarizationBatchParameters'.Please make sure that your schema is correct!
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:529)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:950)
	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:511)
	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class io.swagger.v3.oas.models.media.Schema (java.lang.Boolean is in module java.base of loader 'bootstrap'; io.swagger.v3.oas.models.media.Schema is in unnamed module of loader 'app')
	at org.openapitools.codegen.languages.TypeScriptClientCodegen.addAdditionPropertiesToCodeGenModel(TypeScriptClientCodegen.java:505)
	at org.openapitools.codegen.DefaultCodegen.updateModelForObject(DefaultCodegen.java:2893)
	at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:3111)
	at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1329)
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:524)
	... 4 more

when having the following OpenAPI schema

"AvatarizationBatchParameters": {
        "title": "AvatarizationBatchParameters",
        "required": ["training_dataset_id"],
        "type": "object",
        "properties": {
          "training_dataset_id": {
            "title": "Training Dataset Id",
            "type": "string",
            "format": "uuid"
          },
        },
        "additionalProperties": true
      },

where we have additionalProperties: true at the top level which is a valid spec it seems.

This is related to #13003, but it had additionalProperties that was nested.

Also related is the following issue, but is not specific to typescript:
#9282

The fix was simply to conform to how all the other typescript generators do it, e.g. TypeScriptAxiosClientCodegen.java

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • In case you are adding a new generator, run the following additional script :
    ./bin/utils/ensure-up-to-date
    
    Commit all changed files.
  • File the PR against the correct branch: master (7.0.1 - patch release), 7.1.x (minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@tcrasset tcrasset marked this pull request as ready for review September 7, 2023 08:52
@tcrasset
Copy link
Contributor Author

tcrasset commented Sep 7, 2023

@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04)

Please review :)

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks for your contribution

@macjohnny macjohnny merged commit 005566c into OpenAPITools:master Sep 8, 2023
16 checks passed
@wing328 wing328 added this to the 7.0.1 milestone Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants