OpenAPITools / OpenAPITools/openapi-generator
[REQ] [typescript] Allow for ObjectSerializer configuration
Nobody has claimed this yet.
- 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);
- As you notice I have to pass origin to the baseServer, sdk relies on
windowobject otherwise which is undefined on the server. - I have to forward cookies accordingly or other request-specific headers/data
- There is no option to adjust the ObjectSerializer or disable de-serialization.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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