feat(openapi): convert parameter models to plain objects with serialize/parse functions#409
Open
ALagoni97 wants to merge 6 commits into
Open
feat(openapi): convert parameter models to plain objects with serialize/parse functions#409ALagoni97 wants to merge 6 commits into
ALagoni97 wants to merge 6 commits into
Conversation
… with standalone serialize/parse functions OpenAPI parameters are now generated as TypeScript interfaces with `serializeXxxUrl`/`parseXxxFromUrl` standalone functions instead of class instances, enabling tree-shaking and simpler usage at call sites. AsyncAPI parameters remain class-based (out of scope). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…satisfy sonar complexity Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lient OpenAPI parameters export a standalone serializeXUrl function; AsyncAPI parameters use the class-based getChannelWithParameters method. Add hasSerializeUrl flag to RenderHttpParameters so the channel generator emits the right call at each site, and regenerate the affected fixture. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…erateFunctionImplementation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o feat/plain-object-openapi-parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
serializeXxxUrl(parameters, basePath): stringandparseXxxFromUrl(url, basePath): XxxTypebuildUrlWithParametersinhttp/common-types.tsnow accepts aserializeFncallback instead of a generic with a structural constraint, decoupling the URL builder from the parameter shapeWhy plain objects?
Class instances carry runtime overhead (prototype chain,
newkeyword,instanceofchecks) that is unnecessary for parameter objects which are pure data bags. Interfaces + standalone functions are:new FindPetsByStatusAndCategoryParameters(...)required{ status: 'available' }directlyPossibility of extending to AsyncAPI
AsyncAPI parameters currently remain class-based (
getChannelWithParameters,createFromChannelstatic methods). The same refactor could be applied there:serializeXxxChannel(parameters): string/parseXxxFromChannel(channel): XxxTypepairsrc/codegen/generators/typescript/channels/protocols/each have their ownaddParametersToDependencieswiring that would need updating (analogous to what was done for HTTP here)test/runtime/typescript/test/parameters.spec.ts, AsyncAPI section) would need the class-based assertions replaced with interface + function assertionsThe main reason it was left out of this PR was scope — the HTTP path was self-contained and testable in isolation. The AsyncAPI side touches more protocol renderers and would be a good follow-up PR.
Test plan
npm test— 646/647 tests pass (1 pre-existing skip), all 78 snapshots cleannpm run build— TypeScript compilation succeedsnpm run generate:assets— asset generation succeedsnpm run runtime:typescript:generate— runtime code regenerated and matches committed files🤖 Generated with Claude Code