forked from loafle/openapi-generator-original
[Golang][client] fix file suffix for _test.go (#449)
* add file suffix fix for _test.go * Trigger CI due to previous Shippable race condition * Trigger CI due to previous Shippable race condition * Trigger CI due to previous Travis CI stall * Trigger CI due to previous Travis CI stall * Trigger CI due to previous Shippable race condition * add Go client test testFilenames
This commit is contained in:
parent
8fb413107c
commit
33fcd28dba
@ -201,7 +201,12 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return toModel("model_" + name);
|
||||
name = toModel("model_" + name);
|
||||
if (name.endsWith("_test")) {
|
||||
LOGGER.warn(name + ".go with `_test.go` suffix (reserved word) cannot be used as filename. Renamed to " + name + "_.go");
|
||||
name += "_";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public String toModel(String name) {
|
||||
@ -237,7 +242,12 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.go => pet_api.go
|
||||
return "api_" + underscore(name);
|
||||
name = "api_" + underscore(name);
|
||||
if (name.endsWith("_test")) {
|
||||
LOGGER.warn(name + ".go with `_test.go` suffix (reserved word) cannot be used as filename. Renamed to " + name + "_.go");
|
||||
name += "_";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,4 +72,21 @@ public class GoClientCodegenTest {
|
||||
Assert.assertFalse(bp.isPrimitiveType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilenames() throws Exception {
|
||||
final GoClientCodegen codegen = new GoClientCodegen();
|
||||
|
||||
// Model names are generated from schema / definition names
|
||||
Assert.assertEquals(codegen.toModelFilename("Animal"), "model_animal");
|
||||
Assert.assertEquals(codegen.toModelFilename("AnimalTest"), "model_animal_test_");
|
||||
Assert.assertEquals(codegen.toModelFilename("AnimalFarm"), "model_animal_farm");
|
||||
Assert.assertEquals(codegen.toModelFilename("AnimalFarmTest"), "model_animal_farm_test_");
|
||||
|
||||
// API names are generated from tag names
|
||||
Assert.assertEquals(codegen.toApiFilename("Animal"), "api_animal");
|
||||
Assert.assertEquals(codegen.toApiFilename("Animal Test"), "api_animal_test_");
|
||||
Assert.assertEquals(codegen.toApiFilename("Animal Farm"), "api_animal_farm");
|
||||
Assert.assertEquals(codegen.toApiFilename("Animal Farm Test"), "api_animal_farm_test_");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
# ModelApiResponse
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Code** | **int32** | | [optional] [default to null]
|
||||
**Type_** | **string** | | [optional] [default to null]
|
||||
**Message** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
# ModelReturn
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Return_** | **int32** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
# OuterBoolean
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
# OuterNumber
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
# OuterString
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type OuterBoolean struct {
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type OuterNumber struct {
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type OuterString struct {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user