OpenAPITools / OpenAPITools/openapi-generator

[REQ] [typescript] Allow for ObjectSerializer configuration

Open
#21,662 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Problem

There is no way to disable serialization on the API class. This is important in use-cases like Server Side Rendering or other communication channels that support only primitives and JSON structures.

My problem:

During SSR the frontend is prefetching data from the backend that are streamed from the frontend-server to the frontend-client. As most communication channels this allows only for strictly serializable data to pass through.

My only option right now is to either not use the API for these requests, or to stringify and parse the results in a JSON.

Describe the solution you'd like

  • Ideally, I would like to be able to configure the ObjectSerializer per API instance through the configuration. I would like to extend the Object Serializer class that is currently not exposed by the generated sdk and pass the extended method to be used.

Describe alternatives you've considered

Just exporting the ObjectSerializer class would allow me to monkey-patch it easily on the server.

Additional context

I am using:

  • NextJS v15.4

In SSR, I am initializing an API with server-specific configuration:

  const configuration = SDK.createConfiguration({
    baseServer: new SDK.ServerConfiguration(api_origin, {}),
    httpApi: new ServerHttpLibrary(reqcookies.toString()),
    promiseMiddleware: [new ServerCSRFMiddleware(csrfToken)],
  });

  const ServerAPI = new SDK.DefaultApi(configuration);
  1. As you notice I have to pass origin to the baseServer, sdk relies on window object otherwise which is undefined on the server.
  2. I have to forward cookies accordingly or other request-specific headers/data
  3. There is no option to adjust the ObjectSerializer or disable de-serialization.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing ObjectSerializer usage from SDK.createConfiguration into DefaultApi in the generated TypeScript client. Compare the requested per-instance configuration and serialization-disable behavior with the existing server-specific configuration shown in the issue. Done means an API instance can use the requested serializer behavior without monkey-patching or JSON stringify/parse workarounds.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.