Skip to content

Allow package version to be passed on CLI (Rust fix) #1286

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

Merged
merged 3 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ public RustServerCodegen() {
"Rust crate name (convention: snake_case).")
.defaultValue("openapi_client"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION,
"Rust crate version.")
.defaultValue("1.0.0"));
"Rust crate version."));

/*
* Additional Properties. These values can be passed to the templates and
Expand Down Expand Up @@ -224,8 +223,6 @@ public void processOpts() {

if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
} else {
setPackageVersion("1.0.0");
}

additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "{{{packageName}}}"
version = "{{{appVersion}}}"
version = {{#packageVersion}}"{{{packageVersion}}}"{{/packageVersion}}{{^packageVersion}}"{{{appVersion}}}"{{/packageVersion}}{{! Fill in with packageVersion if defined, which can be passed via a command line argument, Else use appVersion from the Open API spec, which defaults to 1.0.0 if not present.}}
authors = [{{#infoEmail}}"{{{infoEmail}}}"{{/infoEmail}}]
{{#appDescription}}
description = "{{{appDescription}}}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
swagger: '2.0'
info:
description: "This spec is for testing rust-server-specific things"
version: 1.0.0
version: 2.0.0
title: rust-server-test
schemes:
- http
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-server-test"
version = "1.0.0"
version = "2.0.0"
authors = []
description = "This spec is for testing rust-server-specific things"
license = "Unlicense"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To see how to make this your own, look here:

[README]((https://openapi-generator.tech))

- API version: 1.0.0
- API version: 2.0.0

This autogenerated project defines an API crate `rust-server-test` which contains:
* An `Api` trait defining the API in Rust.
Expand Down Expand Up @@ -75,7 +75,7 @@ The server example is designed to form the basis for implementing your own serve

* Set up a new Rust project, e.g., with `cargo init --bin`.
* Insert `rust-server-test` into the `members` array under [workspace] in the root `Cargo.toml`, e.g., `members = [ "rust-server-test" ]`.
* Add `rust-server-test = {version = "1.0.0", path = "rust-server-test"}` under `[dependencies]` in the root `Cargo.toml`.
* Add `rust-server-test = {version = "2.0.0", path = "rust-server-test"}` under `[dependencies]` in the root `Cargo.toml`.
* Copy the `[dependencies]` and `[dev-dependencies]` from `rust-server-test/Cargo.toml` into the root `Cargo.toml`'s `[dependencies]` section.
* Copy all of the `[dev-dependencies]`, but only the `[dependencies]` that are required by the example server. These should be clearly indicated by comments.
* Remove `"optional = true"` from each of these lines if present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.1
info:
description: This spec is for testing rust-server-specific things
title: rust-server-test
version: 1.0.0
version: 2.0.0
servers:
- url: /
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mod mimetypes;
pub use swagger::{ApiError, ContextWrapper};

pub const BASE_PATH: &'static str = "";
pub const API_VERSION: &'static str = "1.0.0";
pub const API_VERSION: &'static str = "2.0.0";


#[derive(Debug, PartialEq)]
Expand Down