Skip to content

Julia template: eval of parse anti-pattern #23941

@luke-kiernan

Description

@luke-kiernan

The julia-server and julia-client generators emit the OpenAPI.property_type discriminator resolver using eval(Base.Meta.parse("ModelName")). The model types are already in scope in the generated module, so straight ModelName works: ~30× faster on the resolver call and pre-compilation friendly, while keeping the behavior the same.

Relevant template pieces: lines 16, 18 here and here: simply replace with return {{modelName}} and return {{.}}.

Worth confirming {{modelName}} is always a valid Julia identifier (true for normal model names) before merging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions