Skip to content

fix: use constrained property names in generated OpenAPI parameter models#381

Merged
jonaslagoni merged 2 commits into
mainfrom
fix/openapi-parameters-constrained-names
Jul 6, 2026
Merged

fix: use constrained property names in generated OpenAPI parameter models#381
jonaslagoni merged 2 commits into
mainfrom
fix/openapi-parameters-constrained-names

Conversation

@ALagoni97

Copy link
Copy Markdown
Contributor

What

Fixes two compilation errors in TypeScript models generated by the OpenAPI parameters preset:

  1. Raw vs constrained property names — generated serialize*/deserialize* methods interpolated the raw OpenAPI parameter name into this.<name> accesses, while Modelina constrains the actual class property to camelCase. Any non-camelCase parameter produced code that fails to compile:

    error TS2551: Property 'Skip' does not exist on type 'GetTransactionsParameters'. Did you mean 'skip'?
    error TS2551: Property 'Cvr' does not exist on type 'PostGuestParameters'. Did you mean 'cvr'?
    
  2. fromUrl calling a method that may not exist — the static fromUrl method unconditionally called instance.deserializeUrl(url), but deserializeUrl is only generated when the operation has query parameters. Every path-parameter-only operation produced:

    error TS2551: Property 'deserializeUrl' does not exist on type 'GetDocumentParameters'. Did you mean 'serializeUrl'?
    

How

  • Parameter serialization configs now carry both the raw wire name (name) and the Modelina-constrained property name (propertyName, resolved via ConstrainedObjectPropertyModel.unconstrainedPropertyName). Generated methods use propertyName for this. accesses and keep name for the wire format (URL templates, query string keys), so serialized URLs are unchanged.
  • fromUrl only emits the instance.deserializeUrl(url) call when the operation has query parameters. Constructor arguments and extractPathParameters result keys also use the constrained property name.
  • Touched deserialization helpers were migrated to the mandatory object-parameters style while changing their signatures.

Verification

  • New regression test: path-only operation must not reference deserializeUrl; Skip/Cvr query parameters must access this.skip/this.cvr while still reading/writing Skip/Cvr on the query string.
  • npm run prepare:pr — passes; snapshots updated (27 updated, 2 added). Every updated snapshot that calls deserializeUrl also defines it. Runtime design surface (test/runtime/typescript) unchanged.

Release

This fix: commit will cut a patch release via semantic-release on merge to main.

🤖 Generated with Claude Code

…dels

The OpenAPI parameters preset interpolated the raw parameter name into
this.<name> accesses of generated serialization/deserialization methods,
while Modelina constrains the actual class property to camelCase. Any
non-camelCase parameter (e.g. 'Skip', 'Cvr') produced code that fails to
compile with TS2551.

The generated static fromUrl method also unconditionally called
instance.deserializeUrl(url), but deserializeUrl is only generated when
the operation has query parameters, so path-parameter-only operations
produced code that fails to compile.

Generated methods now use the Modelina-constrained property name for
property accesses while keeping the raw name for the wire format (URL
templates and query string keys), and fromUrl only calls deserializeUrl
when it exists.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ALagoni97 ALagoni97 requested a review from jonaslagoni as a code owner July 6, 2026 18:12
@netlify

netlify Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploy Preview for the-codegen-project canceled.

Name Link
🔨 Latest commit 1ad59c5
🔍 Latest deploy log https://app.netlify.com/projects/the-codegen-project/deploys/6a4bf142fc9c7f0008dac1e1

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
the-codegen-project Ready Ready Preview, Comment Jul 6, 2026 6:19pm
the-codegen-project-mcp Ready Ready Preview, Comment Jul 6, 2026 6:19pm

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jonaslagoni jonaslagoni merged commit feccd80 into main Jul 6, 2026
20 checks passed
@jonaslagoni

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.72.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants