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][Core] No "type" property in {{modelJson}} of inline response #6150

Closed
5 of 6 tasks
ybelenko opened this issue May 3, 2020 · 0 comments · Fixed by #6153
Closed
5 of 6 tasks

[BUG][Core] No "type" property in {{modelJson}} of inline response #6150

ybelenko opened this issue May 3, 2020 · 0 comments · Fixed by #6153

Comments

@ybelenko
Copy link
Contributor

ybelenko commented May 3, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Variable {{modelJson}} isn't complete for inline responses right now(maybe even for all inline schemas). When I launch any generator with -DdebugModels option the output is:

[main] INFO  o.o.codegen.DefaultGenerator - ############ Model info ############
[ {
  "importPath" : "InlineResponse200",
  "model" : {
    "anyOf" : [ ],
    "oneOf" : [ ],
    "allOf" : [ ],
    "name" : "inline_response_200",
    "classname" : "InlineResponse200",
    "classVarName" : "inlineResponse200",
    "modelJson" : "{\n  \"properties\" : {\n    \"foo\" : {\n      \"type\" : \"string\"\n    },\n    \"bar\" : {\n      \"type\" : \"string\"\n    }\n  }\n}",
    "dataType" : "Object",
    "classFilename" : "InlineResponse200",

It's wrong, because produced schema is invalid(type is required property) and I've set type property in original spec file. Spec file provided below.

openapi-generator version

4.3.1-SNAPSHOT

OpenAPI declaration file content or url
openapi: "3.0.0"
info:
  version: 1.0.0
  title: Test inline response model
  description: Test inline response model.
  license:
    name: MIT
paths:
  /foobar:
    get:
      summary:  No type property in modelJson of InlineResponse200.
      operationId: testOperation
      description: No type property in modelJson of InlineResponse200
      responses:
        200:
          description: InlineResponse200 itself.
          content:
            application/json:
              schema:
                type: object
                properties:
                  foo:
                    type: string
                  bar:
                    type: string
Command line used for generation

Any generator with -DdebugModels option.

Steps to reproduce

Run any generator with option above.

Suggest a fix

{{modelJson}} variable of inline response model should contain type property, because it exists in source spec file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant