swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.03k stars 6.03k forks source link

Add way to retrieve the swagger-codegen version #4548

Closed philip closed 7 years ago

philip commented 7 years ago
Description

It is difficult to determine our swagger-codegen version. Consider reporting the version number somehow, perhaps within the help output and/or by adding a version command.

Swagger-codegen version

2.2.1

Steps to reproduce

When reporting swagger-codegen bugs, I remember trying both "swagger-codegen help" and "swagger-codegen version" to determine the version number, and neither report it.

Instead, to figure it out, I ended up doing the following:

$ which swagger-codegen
$ less /usr/local/bin/swagger-codegen

For example, today on my macOS system it shows exec java -jar /usr/local/Cellar/swagger-codegen/2.2.1/libexec/swagger-codegen-cli.jar "$@" so I assume 2.2.1 is the version there.

Suggest a Fix

Consider adding a version command so swagger-codegen version outputs the version number. Additionally, consider adding the version number to the swagger-codegen help output.

That said, this is a low priority feature request.

wing328 commented 7 years ago

@philip thanks for the suggestion. Have you tried the following?

$ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar version
2.2.2-SNAPSHOT

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help shows the usage:

usage: swagger-codegen-cli <command> [<args>]

The most commonly used swagger-codegen-cli commands are:
    config-help   Config help for chosen lang
    generate      Generate code with chosen lang
    help          Display help information
    langs         Shows available langs
    meta          MetaGenerator. Generator for creating a new template set and configuration for Codegen.  The output will be based on the language you specify, and includes default templates to include.
    version       Show version information

See 'swagger-codegen-cli help <command>' for more information on a specific
command.
philip commented 7 years ago

@wing328 thanks, I missed that, but can now confirm that it exists in 2.2.2 :)

wing328 commented 7 years ago

@philip np. If you've other feedbacks to make Swagger Codegen better, please share with us 😃

(we've just added Swagger Codegen to ProductHunt: https://www.producthunt.com/posts/swagger-codegen, pleae upvote if you found Swagger Codegen useful)

philip commented 7 years ago

@wing328 Interesting, I'll check it out and do find it useful. It also works well for validating swagger files, and/or finding ways to improve them.

This thread brought up two minor help text issues where (a) the help refers to swagger-codegen-cli when I only have swagger-codegen (I understand why, but it's a little odd), and (b) the help text "The most commonly used swagger-codegen-cli commands are" makes me assume that other commands exist that I'm missing out on, like I'm not in the know. I can file a separate bug on this if you wish and agree :)