Search code examples
c#.net-coreopenapi-generator

OpenApi generator - pass mapping from config file


I'm using OpenApi generator to generate http client for api tests. I'm using csharp-netcore generator. I want to pass a mapping for models to reuse api models. The problem is that I have lots of classes and when I provide a mapping for all classes using importMapping option I hit command line max length limitation. I need mapping because namespaces are different for all models and I can't put them all into a single namespace to match auto-generated client. Is there a way to pass this configuration from a config file to bypass command line length limitation?


Solution

  • If by "OpenAPI generator" you mean Swagger codegen than yes, there is a -c option, where you can pass a path to a json config:

    swagger-codegen-cli generate
            [(-c <configuration file> | --config <configuration file>)]
    

    Whether namespace option can be moved into the config file is apparently language dependant: config-help -l {lang}

    Should it not be available you could always tweak the source templates or even Java files to handle this value properly.