OpenAPITools / OpenAPITools/openapi-generator

[REQ][Python-flask] Support type hints

Open
#13,806 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature Server: Python
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Would it be possible to add support for type hints in python flask generator?
It would help me to reduce the number of bugs in my application.

Ex replace this:

class ConnectionInfo(Model):
    """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

    Do not edit the class manually.
    """

    def __init__(self, name=None):  # noqa: E501
        """ConnectionInfo - a model defined in OpenAPI

        :param name: The name of this ConnectionInfo.  # noqa: E501
        :type name: str
        """
        self.openapi_types = {
            'name': str
        }

        self.attribute_map = {
            'name': 'name'
        }

        self.name = name

    @property
    def name(self):
        """Gets the name of this ConnectionInfo.

        Human-readable name of the connection.  # noqa: E501

        :return: The name of this ConnectionInfo.
        :rtype: str
        """
        return self._name

    @name.setter
    def name(self, name):
        """Sets the name of this ConnectionInfo.

        Human-readable name of the connection.  # noqa: E501

        :param name: The name of this ConnectionInfo.
        :type name: str
        """

        self._name = name

with:

class ConnectionInfo(Model):
    """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

    Do not edit the class manually.
    """

    def __init__(self, id:str=None, name=None, references=None, db_info=None):  # noqa: E501
        """ConnectionInfo - a model defined in OpenAPI"""
        self.openapi_types = {
            'name': str
        }

        self.attribute_map = {
            'name': 'name'
        }

        self.name = name

    @property
    def name(self) -> str:
        """Gets the name of this ConnectionInfo.
        Human-readable name of the connection."""
        return self._name

    @name.setter
    def name(self, name: str):
        """Sets the name of this ConnectionInfo.
        Human-readable name of the connection. """
        self._name = name

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Python Flask generator templates and the tests or sample outputs used for generated model classes. Compare their current output with the type-hinted example in the issue; done means generated models consistently include the requested type annotations without breaking existing output expectations.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
backend, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.