Skip to content

Conversation

cb372
Copy link
Contributor

@cb372 cb372 commented Jan 28, 2014

This makes it easy to generate a client with version numbering in sync with the server's advertised API version.

…files.

This makes it easy to generate a client with version numbering in sync
with the server's advertised API version.
@fehguy
Copy link
Contributor

fehguy commented Jan 28, 2014

I think the same can be accomplished without a code change:

  additionalParams ++= Map(
    "artifactId" -> "swagger-petstore", 
    "artifactVersion" -> "1.0.0",
    "groupId" -> "com.wordnik")

Per this:
https://github.com/wordnik/swagger-codegen/blob/master/samples/client/petstore/java/JavaPetstoreCodegen.scala#L37-L40

and this:
https://github.com/wordnik/swagger-codegen/blob/master/src/main/resources/Java/pom.mustache#L4

@cb372
Copy link
Contributor Author

cb372 commented Jan 28, 2014

That's true, but this change makes it easier to keep the client version in sync with the API version. Just change the API version once on the server, and the client version will automatically be updated next time you generate. I feel like this is a reasonable default behaviour.

Of course, there are cases where you want to version the client separately from the API, e.g. if you tweak the client code even though the API has not changed. In that case, the method you suggested works fine.

People may also want to generate a version number using a combination of the API version and additional params, e.g.:

additionalParams += ("minorVersion" -> "123")
<version>{{apiVersion}}.{{minorVersion}}</version>

fehguy added a commit that referenced this pull request Feb 19, 2014
Add the API version to the Mustache model when generating supporting files
@fehguy fehguy merged commit ab7e152 into swagger-api:master Feb 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants