forked from loafle/openapi-generator-original
better handling of reserved words for sintatra, dart
This commit is contained in:
@@ -211,7 +211,8 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
@@ -273,7 +274,9 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
return camelize(operationId, true);
|
||||
|
||||
@@ -182,7 +182,8 @@ public class SinatraServerCodegen extends DefaultCodegen implements CodegenConfi
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
@@ -224,7 +225,9 @@ public class SinatraServerCodegen extends DefaultCodegen implements CodegenConfi
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
||||
String newOperationId = underscore("call_" + operationId);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
return underscore(operationId);
|
||||
|
||||
23
samples/client/petstore/dart/swagger/.swagger-codegen-ignore
Normal file
23
samples/client/petstore/dart/swagger/.swagger-codegen-ignore
Normal file
@@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
@@ -604,6 +604,8 @@ definitions:
|
||||
complete:
|
||||
type: "boolean"
|
||||
default: false
|
||||
title: "Pet Order"
|
||||
description: "An order for a pets from the pet store"
|
||||
xml:
|
||||
name: "Order"
|
||||
Category:
|
||||
@@ -614,6 +616,8 @@ definitions:
|
||||
format: "int64"
|
||||
name:
|
||||
type: "string"
|
||||
title: "Pet catehgry"
|
||||
description: "A category for a pet"
|
||||
xml:
|
||||
name: "Category"
|
||||
User:
|
||||
@@ -638,6 +642,8 @@ definitions:
|
||||
type: "integer"
|
||||
format: "int32"
|
||||
description: "User Status"
|
||||
title: "a User"
|
||||
description: "A User who is purchasing from the pet store"
|
||||
xml:
|
||||
name: "User"
|
||||
Tag:
|
||||
@@ -648,6 +654,8 @@ definitions:
|
||||
format: "int64"
|
||||
name:
|
||||
type: "string"
|
||||
title: "Pet Tag"
|
||||
description: "A tag for a pet"
|
||||
xml:
|
||||
name: "Tag"
|
||||
Pet:
|
||||
@@ -685,6 +693,8 @@ definitions:
|
||||
- "available"
|
||||
- "pending"
|
||||
- "sold"
|
||||
title: "a Pet"
|
||||
description: "A pet for sale in the pet store"
|
||||
xml:
|
||||
name: "Pet"
|
||||
ApiResponse:
|
||||
@@ -697,6 +707,8 @@ definitions:
|
||||
type: "string"
|
||||
message:
|
||||
type: "string"
|
||||
title: "An uploaded response"
|
||||
description: "Describes the result of uploading an image resource"
|
||||
externalDocs:
|
||||
description: "Find out more about Swagger"
|
||||
url: "http://swagger.io"
|
||||
|
||||
Reference in New Issue
Block a user