Skip to content

[php] bugfix: Array and Map inner schema definition can be missing. #1586

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

Merged
merged 1 commit into from
Dec 10, 2018

Conversation

DenKoren
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

/cc @jebentier @dkarlovi @mandrean @jfastnacht @ackintosh @ybelenko

Bugfix is the same to #1363 but for PHP code generator.

This bug appeared during mattermost v4 api code generation (at least for the master version. At the moment of test it was 87a2f9b014f07e4431aa5e884029a5bb4e9f0b68)

The error produced by missing schema definition is listed below.

[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
Exception in thread "main" java.lang.RuntimeException: Could not process model 'inline_object_43'.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:434)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:865)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:349)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:62)
Caused by: java.lang.NullPointerException
at org.openapitools.codegen.utils.ModelUtils.isArraySchema(ModelUtils.java:339)
at org.openapitools.codegen.languages.AbstractPhpCodegen.getTypeDeclaration(AbstractPhpCodegen.java:345)
at org.openapitools.codegen.languages.AbstractPhpCodegen.getTypeDeclaration(AbstractPhpCodegen.java:348)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:1966)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3391)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3362)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3349)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1675)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1103)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:429)

Copy link
Contributor

@ackintosh ackintosh left a comment

Choose a reason for hiding this comment

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

Thanks for this PR, which looks good to me.

@ackintosh
Copy link
Contributor

By the way, in OpenAPI-Specification, an inner schema must be defined. So I think root of problem is mattermost-openapi-v4.yaml and swagger-parser.

@wing328 wing328 merged commit a27224e into OpenAPITools:master Dec 10, 2018
@wing328 wing328 added this to the 4.0.0 milestone Dec 30, 2018
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants