-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Labels
Description
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?
4.2.2 - Have you search for related issues/PRs?
- What's the actual output vs expected output?
I would've expected this to generate code that compiles/runs. But the.from_dictseems invalid Python syntax. - [Optional] Bounty to sponsor the fix (example)
Description
When using this spec as input:
openapi: "3.0.0"
info:
title: "My API"
version: "0.0.1"
paths:
/invoices:
get:
parameters:
- name: filter
in: query
description: Filter parameters
required: false
schema:
type: object
properties:
field:
type: string
responses:
'200':
description: An array of invoices
content:
application/json:
schema:
type: array
items:
type: object
properties:
number:
type: integer
format: int64a default_controller.py is generated containing the following code:
import connexion
import six
from openapi_server.models.filter import Filter # noqa: E501
from openapi_server.models.inline_response200 import InlineResponse200 # noqa: E501
from openapi_server import util
def invoices_get(filter=None): # noqa: E501
"""invoices_get
# noqa: E501
:param filter: Filter parameters
:type filter: dict | bytes
:rtype: List[InlineResponse200]
"""
if connexion.request.is_json:
filter = .from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!'The .from_dict is invalid Python syntax.
Trying to run the generated application, results in the following error:
jsonschema.exceptions.RefResolutionError: Unresolvable JSON pointer: 'components/parameters/filter'openapi-generator version
4.2.2
OpenAPI declaration file content or url
See above.
Command line used for generation
openapi-generator generate -i ./openapi.yaml -g python-flask -o ./generated
Steps to reproduce
- Use above command and openapi.yaml to generate python-flask code.
Related issues/PRs
Suggest a fix
I suppose the .from_dict needs to be prefixed by a class name.
highvight, gabortim, praveen049, hsgreen and VikramVasudevan