OpenAPITools / OpenAPITools/openapi-generator

Objectmapper instance should not be created per api client invocation.

Open
#11,686 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

Objectmappers are heavy according to what I have read. Instead it is encouraged to use ObjectReader and ObjectWriter as lightweight alternatives.

For now, we suggest to create new APIClient per thread as its not thread safe. This will also result in creation of new object mapper per invocation.

ref:

image image

For some cases, objectmapper is not configurable, for that we can allow setting mapper in apiclient via setters.

Can we add this improvement in future?

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 locating APIClient and where its ObjectMapper is created for each invocation. Review the thread-safety and configurability constraints described in the issue, then define completion as avoiding unnecessary per-invocation mapper creation while supporting configurable mapping where needed and covering the behavior with tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.