[Python] add project name to setup.py in python client (#5836)

* add project name to setup.py in python client

* update python README to use project name

* add cli option project name for python
This commit is contained in:
wing328 2017-06-14 00:18:54 +08:00 committed by GitHub
parent b61dfefa5b
commit d6c717263c
8 changed files with 673 additions and 653 deletions

View File

@ -96,6 +96,7 @@ public class CodegenConstants {
public static final String ENSURE_UNIQUE_PARAMS = "ensureUniqueParams";
public static final String ENSURE_UNIQUE_PARAMS_DESC = "Whether to ensure parameter names are unique in an operation (rename parameters that are not).";
public static final String PROJECT_NAME = "projectName";
public static final String PACKAGE_NAME = "packageName";
public static final String PACKAGE_VERSION = "packageVersion";

View File

@ -1,4 +1,4 @@
# {{packageName}}
# {{{projectName}}}
{{#appDescription}}
{{{appDescription}}}
{{/appDescription}}

View File

@ -5,7 +5,7 @@
import sys
from setuptools import setup, find_packages
NAME = "{{packageName}}"
NAME = "{{{projectName}}}"
VERSION = "{{packageVersion}}"
{{#apiInfo}}
{{#apis}}

View File

@ -9,6 +9,7 @@ import java.util.Map;
public class PythonClientOptionsProvider implements OptionsProvider {
public static final String PACKAGE_NAME_VALUE = "swagger_client_python";
public static final String PROJECT_NAME_VALUE = "swagger-client-python";
public static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
public static final String PACKAGE_URL_VALUE = "";
@ -22,6 +23,7 @@ public class PythonClientOptionsProvider implements OptionsProvider {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(PythonClientCodegen.PACKAGE_URL, PACKAGE_URL_VALUE)
.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
.put(CodegenConstants.PROJECT_NAME, PROJECT_NAME_VALUE)
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true")
.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true")

View File

@ -28,6 +28,8 @@ public class PythonClientOptionsTest extends AbstractOptionsTest {
new Expectations(clientCodegen) {{
clientCodegen.setPackageName(PythonClientOptionsProvider.PACKAGE_NAME_VALUE);
times = 1;
clientCodegen.setProjectName(PythonClientOptionsProvider.PROJECT_NAME_VALUE);
times = 1;
clientCodegen.setPackageVersion(PythonClientOptionsProvider.PACKAGE_VERSION_VALUE);
times = 1;
clientCodegen.setPackageUrl(PythonClientOptionsProvider.PACKAGE_URL_VALUE);

View File

@ -1,4 +1,4 @@
# petstore_api
# petstore-api
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:

View File

@ -14,7 +14,7 @@
import sys
from setuptools import setup, find_packages
NAME = "petstore_api"
NAME = "petstore-api"
VERSION = "1.0.0"
# To install the library, run the following
#