Skip to content

Passing of parameters and supporting files is a bit clunky #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ericmartineau opened this issue Apr 15, 2015 · 7 comments
Closed

Passing of parameters and supporting files is a bit clunky #643

ericmartineau opened this issue Apr 15, 2015 · 7 comments

Comments

@ericmartineau
Copy link

We have several projects that we'd like to generate sdks for (java). They each have potentially different package names, groupIds, artifactIds, and version. Additionally, we are doing some slightly different things with the generation (gradle instead of maven, etc).

Right now, swagger-codegen requires too much changing of code within the actual swagger-codegen project IMO, whereas most of what we're doing is simply passing in parameters to be accessed in the template models. Also, the only way to add supporting files is to modify the swagger-codegen classes.

If we had the ability to read a properties file that could modify any of the core properties (packages, artifacts, versions, etc), and another file that could specify additional supporting files, I believe we could make do with the vanilla Java client codegen. So, I started modifying the Generate class to read these files, but now I'm running into the problem that these properties are scoped protected, so I can't set on the Codegen class itself. So, I added them to additionalProperties (I saw that someone else had done this with templateDir), but the read patterns are inconsistent - everything ends up in a Model eventually, but there are helper methods for determining folders, eg.JavaClientCodgen.modelFileFolder() that still read the protected property.

I can see two solutions:

  1. I can create my own JavaClientCodegen subclass that reads from property files which will work for me, or
  2. We discuss a potentially better way to pass properties into the CLI, or
  3. I dont' know what I'm talking about and somebody can educate me :)
@who
Copy link
Contributor

who commented Apr 15, 2015

@smartytime It sounds like #616 will solve some of your concerns. Please have a look and provide some feedback.

@ericmartineau
Copy link
Author

Cool - looks good.

I love the idea of a json config object -- something structured that could also account for adding supporting files. I'd personally rather just use that than worry about passing a ton of command line args.

The only other thing that would be really nice IMO is a simple way to add basic transfromations to the model (without having to recompile swagger-codegen). Sometimes you want to make the first letter lowercase, or combine two fields. It would be really nice to be able to do something like that without having to create or modify a Codegen class.

@webron
Copy link
Contributor

webron commented May 4, 2015

@smartytime - Since #616 covers the configuration aspects, can you add your comments there so we can consolidate issues?

As for the transformations, I'd suggest opening a separate feature request for it. It's an interesting idea.

@cbornet
Copy link
Contributor

cbornet commented Jul 13, 2015

Hello,

#616 has been closed. It was a really great improvement on additionalProperties but unfortunately, it is still impossible to add supportingFiles via a config file and the only way is to modify the generator itself. I think since supportingFiles depend on additionalProperties, it is not as easy to implement. Maybe the JSON file could contain mustache-like syntax to reuse the previously set additionalProperties.

@wing328
Copy link
Contributor

wing328 commented Jul 13, 2015

@cbornet do you mind sharing with me the additional file you want to include? What's the purpose of that additional file?

@cbornet
Copy link
Contributor

cbornet commented Jul 14, 2015

@wing328 the point is to have the user define its own additional files depending on what he wants to do. @smartytime gives the example of generating a gradle file instead of a pom but there are a lot of other possibilities.

@fehguy
Copy link
Contributor

fehguy commented Oct 25, 2015

OK for now, you can't supply arbitrary files to the generation command. They have to be mapped via code. We'll add support for another mechanism to do so but for now, it's simply not possible and not a defect. Please open a new ticket if you have suggestions on the syntax or behavior and it can be considered for the next release.

@fehguy fehguy closed this as completed Oct 25, 2015
@fehguy fehguy modified the milestone: v2.1.4 Oct 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants