Skip to content

Commit f0678e7

Browse files
committed
fixup! show alias
1 parent 4dc1db1 commit f0678e7

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/griffe_pydantic/_internal/static.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ def _process_class(cls: Class, *, processed: set[str], schema: bool = False) ->
268268
_logger.debug(f"Could not import class {cls.path} for JSON schema")
269269
return
270270
try:
271-
cls.extra[common._self_namespace]["schema"] = common._json_schema(
272-
true_class,
273-
)
271+
cls.extra[common._self_namespace]["schema"] = common._json_schema(true_class)
274272
except Exception as exc: # noqa: BLE001
275273
# Schema generation can fail and raise Pydantic errors.
276274
_logger.debug("Failed to generate schema for %s: %s", cls.path, exc)
@@ -285,7 +283,12 @@ def _process_class(cls: Class, *, processed: set[str], schema: bool = False) ->
285283
_process_class(member, processed=processed, schema=schema) # ty: ignore[invalid-argument-type]
286284

287285

288-
def _process_module(mod: Module, *, processed: set[str], schema: bool = False) -> None:
286+
def _process_module(
287+
mod: Module,
288+
*,
289+
processed: set[str],
290+
schema: bool = False,
291+
) -> None:
289292
"""Handle Pydantic models in a module."""
290293
if mod.canonical_path in processed:
291294
return

src/griffe_pydantic/templates/material/_base/pydantic_model.html.jinja

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,16 @@
3131
{% for name, field in fields.items() %}
3232
<li>
3333
<code><autoref optional hover identifier="{{ field.path }}">{{ name }}</autoref></code>
34-
{% if field.extra.griffe_pydantic.alias %}
35-
(<code><em>{{ field.extra.griffe_pydantic.alias }}</em></code>)
34+
{% if field.extra.griffe_pydantic.validation_alias or field.extra.griffe_pydantic.serialization_alias %}
35+
(
36+
{%- if field.extra.griffe_pydantic.validation_alias -%}
37+
validation alias: <code>{{ field.extra.griffe_pydantic.validation_alias }}</code>
38+
{% if field.extra.griffe_pydantic.serialization_alias %}, {% endif %}
39+
{%- endif -%}
40+
{%- if field.extra.griffe_pydantic.serialization_alias -%}
41+
serialization alias: <code>{{ field.extra.griffe_pydantic.serialization_alias }}</code>
42+
{%- endif -%}
43+
)
3644
{% endif %}
3745
{% with expression = field.annotation %}
3846
(<code>{% include "expression.html.jinja" with context %}</code>)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{% extends "_base/pydantic_attribute_alias.html.jinja" %}
1+
{% extends "_base/pydantic_field.html.jinja" %}

0 commit comments

Comments
 (0)