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] Nested components are generated with no type #1889

Open
4 of 5 tasks
awrichar opened this issue Jan 11, 2019 · 1 comment
Open
4 of 5 tasks

[BUG] Nested components are generated with no type #1889

awrichar opened this issue Jan 11, 2019 · 1 comment

Comments

@awrichar
Copy link

awrichar commented Jan 11, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • 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

When generating code for python-flask, the generated YAML spec does not include types for nested components. Unclear if this generation problem is specific to python-flask (seems to be a more generic issue with YAML generation), but it causes automatic validation to fail when passing these types to the Flask server in a request.

openapi-generator version

4.0.0-beta

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  version: "1.0"
  title: "{{title}}"
servers:
  - url: /v1
paths:
  /parent:
    post:
      operationId: create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Parent"
      responses:
        200:
          description: OK
components:
  schemas:
    Parent:
      type: object
      properties:
        child:
          type: object
          properties:
            grandchild:
              type: string
Command line used for generation
./titan/openapi-generator-cli.sh generate -g python-flask -i openapi.yaml -o gen
Steps to reproduce

After running the generator command, the generated file gen/openapi_server/openapi/openapi.yaml contains these component definitions:

components:
  schemas:
    Parent:
      example:
        child:
          grandchild: grandchild
      properties:
        child:
          $ref: '#/components/schemas/Parent_child'
      type: object
    Parent_child:
      example:
        grandchild: grandchild
      properties:
        grandchild:
          type: string

Notice that the generated Parent_child component has no type. This causes it to fail with Body property 'child' not defined in body schema when passing a Parent object via request body.

Adding type: object to the Parent_child definition causes things to work properly.

@i5heu
Copy link

i5heu commented Jul 3, 2019

This Bug exist in typescript-fetch too!

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