openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[REQ] Add support for excluding paths/operations from code generation (online generator module)

Open GeorgeFkd opened this issue 1 year ago • 5 comments

I have started working on it and will soon create a PR(some refactor is still needed, testing and some more effort).

For the module openapi-generator-online it would be useful if the user could only choose a few of the operations included in an openapi specification and generate the code for those only.

GeorgeFkd avatar May 15 '24 14:05 GeorgeFkd

in openapi normalizer, there's a rule called FILTER: https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#openapi-normalizer

is that what you're looking for?

wing328 avatar May 15 '24 15:05 wing328

Yes that is the feature, let the user select what he wants generated, but in the online version not on the CLI.

GeorgeFkd avatar May 15 '24 15:05 GeorgeFkd

i think the normalizer is also available to the online service if i'm not mistaken

wing328 avatar May 16 '24 13:05 wing328

It is probably somewhere buried in the options object, im reading up on the docs and the sourcecode to find it.

GeorgeFkd avatar May 16 '24 16:05 GeorgeFkd

@wing328 Having tried it by setting in the options object "FILTER":"operationId:addPet|getPetById and read lots of the source code it is improbable that it is actually available in the online service.

This is where the options:Map<String,String> is being processed in Generator.class in org/openapitools/codegen/online/service/Generator.java

if (opts.getOptions() != null) {
            codegenConfig.additionalProperties().putAll(opts.getOptions());
            codegenConfig.additionalProperties().put("openAPI", openapi);
}

Its implementation is not difficult,it involves adding an openapi-normalizer:List<String> property in the GeneratorInput.class, i could work on it.

GeorgeFkd avatar May 23 '24 15:05 GeorgeFkd