Skip to content

Commit

Permalink
Add auto-generated rockspec file to Lua API client (#7475)
Browse files Browse the repository at this point in the history
* add luarocks spec

* remove trailing spaces

* remove rockspec filename option

* update lua rockspec

* update rockspec based on feedback

* remove configuration which is not needed

* remove api_client, which is no longer needed
  • Loading branch information
wing328 committed Jan 27, 2018
1 parent 15b3dfb commit a2410b2
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 491 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
static Logger LOGGER = LoggerFactory.getLogger(LuaClientCodegen.class);

protected String packageName = "swagger";
protected String packageVersion = "1.0.0";
protected String packageName = "swagger-client";
protected String packageVersion = "1.0.0-1";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
protected String luaRocksFilename = "swagger-client-1.0.0-1.rockspec";

public CodegenType getTag() {
return CodegenType.CLIENT;
Expand Down Expand Up @@ -104,9 +105,9 @@ public LuaClientCodegen() {

cliOptions.clear();
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Lua package name (convention: lowercase).")
.defaultValue("swagger"));
.defaultValue("swagger-client"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Lua package version.")
.defaultValue("1.0.0"));
.defaultValue("1.0.0-1"));
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
.defaultValue(Boolean.TRUE.toString()));

Expand All @@ -126,19 +127,18 @@ public void processOpts() {

if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} else {
setPackageName("swagger");
}

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

additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);

// set rockspec based on package name, version
setLuaRocksFilename(packageName + "-" + packageVersion + ".rockspec");

additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath);

Expand All @@ -154,6 +154,7 @@ public void processOpts() {
//supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("luarocks.mustache", "", luaRocksFilename));
//supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.lua"));
//supportingFiles.add(new SupportingFile("api_client.mustache", "", "api_client.lua"));
//supportingFiles.add(new SupportingFile("api_response.mustache", "", "api_response.lua"));
Expand Down Expand Up @@ -443,6 +444,10 @@ public void setPackageVersion(String packageVersion) {
this.packageVersion = packageVersion;
}

public void setLuaRocksFilename(String luaRocksFilename) {
this.luaRocksFilename = luaRocksFilename;
}

@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Class | Method | HTTP request | Description
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
{{#authMethods}}
## {{{name}}}
{{#isApiKey}}- **Type**: API key
{{#isApiKey}}- **Type**: API key

Example
```
Expand Down
Loading

0 comments on commit a2410b2

Please sign in to comment.