Using Linear's schema (https://studio.apollographql.com/public/Linear-API/variant/current/schema/reference)
schema.json
Command:
datamodel-codegen \
--input schema.graphql \
--input-file-type graphql \
--output models.py \
--output-model-type pydantic_v2.BaseModel \
--target-pydantic-version 2.11 \
--use-annotated \
--field-constraints \
--snake-case-field \
--use-serialization-alias \
--use-schema-description \
--graphql-no-typename \
--class-name-prefix Linear \
--enable-command-header \
--enable-faux-immutability \
--enable-version-header \
--use-generic-base-class \
--use-double-quotes
Running:
Yields:
File "/Users/eimantas.gecas/git/hologen-core/infrastructure/hgctl/.venv/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py", line 2227, in _apply_annotations
schema = get_inner_schema(source_type)
File "/Users/eimantas.gecas/git/hologen-core/infrastructure/hgctl/.venv/lib/python3.13/site-packages/pydantic/_internal/_schema_generation_shared.py", line 83, in __call__
schema = self._handler(source_type)
File "/Users/eimantas.gecas/git/hologen-core/infrastructure/hgctl/.venv/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py", line 2206, in inner_handler
schema = self._generate_schema_inner(obj)
File "/Users/eimantas.gecas/git/hologen-core/infrastructure/hgctl/.venv/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py", line 1028, in _generate_schema_inner
return self.match_type(obj)
~~~~~~~~~~~~~~~^^^^^
File "/Users/eimantas.gecas/git/hologen-core/infrastructure/hgctl/.venv/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py", line 1104, in match_type
return self._type_alias_type_schema(obj)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "/Users/eimantas.gecas/git/hologen-core/infrastructure/hgctl/.venv/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py", line 1357, in _type_alias_type_schema
raise PydanticUndefinedAnnotation.from_name_error(e) from e
pydantic.errors.PydanticUndefinedAnnotation: name 'AgentActivityActionContent' is not defined
For further information visit https://errors.pydantic.dev/2.12/u/undefined-annotation
Looking at the model, it appears that when the flag --class-name-prefix Linear is set, TypeAliasType does not use it.
# Content for different types of agent activities.
LinearAgentActivityContent = TypeAliasType(
"LinearAgentActivityContent",
Union[
"AgentActivityActionContent",
"AgentActivityElicitationContent",
"AgentActivityErrorContent",
"AgentActivityPromptContent",
"AgentActivityResponseContent",
"AgentActivityThoughtContent",
],
)
Using Linear's schema (https://studio.apollographql.com/public/Linear-API/variant/current/schema/reference)
schema.json
Command:
Running:
Yields:
Looking at the model, it appears that when the flag
--class-name-prefix Linearis set, TypeAliasType does not use it.