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
  • #4873
Closed
Open
Issue created Dec 27, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [python-flask] invalid `.from_dict` generated when using object as query parameter

Created by: Tohnmeister

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_dict seems 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: int64

a 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.

Assignee
Assign to
Time tracking