openapi-python-generator icon indicating copy to clipboard operation
openapi-python-generator copied to clipboard

description and / or title of properties and endpoints

Open nklamann opened this issue 1 year ago • 0 comments

It would be useful if the generated python code would contain docstrings from the schema.

This works for classes only. It would be great for service endpoints and attributes too.

This is not a templating issue. I tested this with vour example here https://marcomuellner.github.io/openapi-python-generator/tutorial/ and the follwing template

# generated by openapi-python generator
from typing import *
from pydantic import BaseModel, Field
{% for property in properties %}
{% if property.type.import_types is not none %}
{% for import_type in property.type.import_types %}
{{ import_type }}
{% endfor %}
{% endif %}
{% endfor %}

class {{ schema_name }}(BaseModel):

    """
    {{ schema.title }}
    {{ schema.description }}
    """

    {% for property in properties %}

    {{ property.name | replace("@","") | replace("-","_") }} : {{ property.type.converted_type | safe }} = Field(alias="{{ property.name }}" {% if not property.required %}, default = {{ property.default }} {% endif %})

    """
    {{ property.title }}
    {{ property.description }}
    """

    {% endfor %}

Team.py has no docstrigs fro its attributes

nklamann avatar Dec 20 '24 13:12 nklamann