Expose ids into template context
ZipFile opened this issue · 0 comments
Is your feature request related to a problem? Please describe.
I want to implement basic schema registry out of generated models, so I need a way to include extra identifying info into my models.
Describe the solution you'd like
It would be nice for JSON Schema's $id
and OpenAPI's operationId
to be available within the template. Potentially something like x-id
might be ok too, but if we're going this way, it is better to expose all of the x-
fields.
Ideal solution would be an ability to do something like this in the template:
{%- if id_ %}
_id: ClassVar[str] = "{{ id_ }}"
{%- endif %}
Describe alternatives you've considered
I've glanced the code, but it looks like there is no obvious way to extract ids. self.reference.path
of DataModel
instances looks unique enough, but that's not exactly an id defined in the schema. Given the nature of the schemas I work with, exposing it would be enough for now.