Skip to content

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

Open
@ghostbuster91

Description

@ghostbuster91

The idea is very similar to #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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions