OpenAPITools / OpenAPITools/openapi-generator

[REQ] scala-akka-server and Json marshalling

Open
#9,094 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Problem

Akka stub servers, and more generally scala stubs, can rely on a multitude of Json parsers.
Two approaches are therefore possible when generating projects via openapi: either choose one, or let the user choose his own, by just providing an interface (which is the case in scala-akka-http-server).

Each solution has its advantages and disadvantages.
Choosing for the user will often mean having unnecessary dependencies (why have spray-json when I already have jackson?).
On the other hand, having a totally generic stub leads to generate files that are not directly usable. A whole layer of serialization has to be added by the user, which makes the use of the akka-http module more complex.

Proposal 1

No change in current behavior.
Users of scala-akka-http have to guess how to use the generated code.

Pros:

  • nothing to do

Cons:

  • the module seems unusable at first.
Proposal 2

We generate code with a predefined Json dependency.
Pros :

  • the generated code is ready to use
  • the tedious task of proposing a marshaller / unmarshaller for each class or model is now done by the generator

Cons:

  • the chosen library will not be suitable for everyone
Proposal 3

We generate the same code as now, but with an option to generate marshallers.
This option could allow to specify the json backend to use, free afterwards to make PR to add the backend of his choice.

Pros:

  • the best of both worlds: code that can compile out of the box, and the possibility to choose your json backend

Cons:

  • the mustache template will become very complex if it has to contain the generation of marshallers for all existing backends

Conclusion

As a commiter and user of this generator, I would like it to be as useful to others as it is to me, so I am willing to modify it to best fit the expectations and policy of the project.

Looking forward to reading your feedbacks, comments, desires, criticisms, thank you!

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

Begin by reviewing the scala-akka-server and scala-akka-http-server generation paths and the mustache template mentioned in the proposal. First resolve which marshalling approach the project wants, then define completion as an agreed option or default that produces usable generated Scala server code and is covered by the relevant generator tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.