OpenAPITools / OpenAPITools/openapi-generator

[REQ] Allow generating only src/main/scala in sttp generator

Open
#6,685 2 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

The idea is very similar to https://github.com/OpenAPITools/openapi-generator/issues/6155. I would like to create a compiler plugin for sbt which generates only scala classes from openapi specification and puts them on the classpath.

As far as I got familiar with openApi generators while working on #6684 it seems to me that it might be quite easy to achieve that by just adding a single if statement into the sttpClientCode generator.

So the change would affect this method where we add templates to process:

    @Override
    public void processOpts() {
        super.processOpts();
        properties.forEach(p -> p.updateAdditionalProperties(additionalProperties));
        invokerPackage = INVOKER_PACKAGE.getValue(additionalProperties);
        apiPackage = API_PACKAGE.getValue(additionalProperties);
        modelPackage = MODEL_PACKAGE.getValue(additionalProperties);

        supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
        supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
        final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator);
        supportingFiles.add(new SupportingFile("jsonSupport.mustache", invokerFolder, "JsonSupport.scala"));
        supportingFiles.add(new SupportingFile("project/build.properties.mustache", "project", "build.properties"));
        supportingFiles.add(new SupportingFile("dateSerializers.mustache", invokerFolder, "DateSerializers.scala"));
}

First of all I might be wrong and it is not so simple after all. The second question is whether it should be done for the rest of scala generators or even for all generators.

@clasnake (2017/07), @jimschubert (2017/09) heart, @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04)

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 with the sttpClientCode generator's processOpts() method and the supporting files listed there; review issue #6155 and the related work in #6684 for context. Determine the intended scope across Scala generators, then verify that the requested mode generates only src/main/scala output suitable for an sbt classpath without the other listed supporting files.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, scala
Domain
build-system, tooling
Issue type
Feature
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.