Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #10280
Closed
Open
Issue created Aug 28, 2021 by Administrator@rootContributor

[BUG] python-fastapi: pytest fails

Created by: Minyus

Description

pytest fails as follows:

#16 0.795 =================================== FAILURES ===================================
#16 0.795 _______________________________ test_place_order _______________________________
#16 0.795
#16 0.795 client = <starlette.testclient.TestClient object at 0x7f085de03210>
#16 0.795
#16 0.795 def test_place_order(client: TestClient):
#16 0.795 """Test case for place_order
#16 0.795
#16 0.795 Place an order for a pet
#16 0.795 """
#16 0.795 > body = openapi_server.Order()
#16 0.795 E NameError: name 'openapi_server' is not defined
#16 0.795
#16 0.795 tests/test_store_api.py:69: NameError
openapi-generator version

5.2.1

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml

Generation Details

Run: docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v5.2.1 generate -i /local/openapi.yaml -g python-fastapi -o /local

Steps to reproduce

Run: docker-compose up (or docker-compose build --no-cache)

Related issues/PRs

None

Suggest a fix

Remove openapi_server. and add .dict() in the generated test code, for example:

Original:

    body = openapi_server.Order()

Modification:

    body = Order().dict()
Assignee
Assign to
Time tracking