forked from loafle/openapi-generator-original
Fixes to go API documentation generation (#7963)
* More fixes to go doc generation * Regenerate samples * Fix indent * Remove additonal bracket on time objects
This commit is contained in:
@@ -452,14 +452,10 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
}
|
||||
|
||||
for (CodegenOperation operation : operationList) {
|
||||
boolean needTimeImport = false;
|
||||
for (CodegenParameter cp : operation.allParams) {
|
||||
cp.vendorExtensions.put("x-go-example", constructExampleCode(cp, modelMaps, processedModelMaps));
|
||||
if (cp.isDateTime || cp.isDate) { // datetime or date
|
||||
needTimeImport = true;
|
||||
}
|
||||
}
|
||||
if (needTimeImport) {
|
||||
if (processedModelMaps.containsKey("time.Time")) {
|
||||
operation.vendorExtensions.put("x-go-import", " \"time\"");
|
||||
}
|
||||
processedModelMaps.clear();
|
||||
@@ -499,6 +495,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
} else if (codegenParameter.isUri) { // URL
|
||||
return "\"https://example.com\"";
|
||||
} else if (codegenParameter.isDateTime || codegenParameter.isDate) { // datetime or date
|
||||
processedModelMap.put("time.Time", 1);
|
||||
return "time.Now()";
|
||||
} else if (codegenParameter.isFile) {
|
||||
return "os.NewFile(1234, \"some_file\")";
|
||||
@@ -513,6 +510,9 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
// look up the model
|
||||
if (modelMaps.containsKey(codegenParameter.dataType)) {
|
||||
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, processedModelMap);
|
||||
} else if (codegenParameter.isDateTime || codegenParameter.isDate) { // datetime or date
|
||||
processedModelMap.put("time.Time", 1);
|
||||
return "time.Now()";
|
||||
} else {
|
||||
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
|
||||
return "TODO";
|
||||
@@ -551,6 +551,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
} else if (codegenProperty.isUri) { // URL
|
||||
return "\"https://example.com\"";
|
||||
} else if (codegenProperty.isDateTime || codegenProperty.isDate) { // datetime or date
|
||||
processedModelMap.put("time.Time", 1);
|
||||
return "time.Now()";
|
||||
} else { // numeric
|
||||
String example;
|
||||
@@ -566,6 +567,9 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
// look up the model
|
||||
if (modelMaps.containsKey(codegenProperty.dataType)) {
|
||||
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, processedModelMap);
|
||||
} else if (codegenProperty.isDateTime || codegenProperty.isDate) { // datetime or date
|
||||
processedModelMap.put("time.Time", 1);
|
||||
return "time.Now()";
|
||||
} else {
|
||||
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenProperty.dataType);
|
||||
return "\"TODO\"";
|
||||
@@ -601,6 +605,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
for (CodegenProperty codegenProperty : codegenModel.requiredVars) {
|
||||
propertyExamples.add(constructExampleCode(codegenProperty, modelMaps, processedModelMap));
|
||||
}
|
||||
return "*" + goImportAlias + ".New" + model + "(" + StringUtils.join(propertyExamples, ", ") + ")";
|
||||
return "*" + goImportAlias + ".New" + toModelName(model) + "(" + StringUtils.join(propertyExamples, ", ") + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ Other parameters are passed through a pointer to a api{{{nickname}}}Request stru
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
|
||||
{{^isPathParam}} **{{paramName}}** | {{#isContainer}}{{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{#baseType}}{{baseType}}{{/baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**map[string]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{#baseType}}{{baseType}}{{/baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{#baseType}}{{baseType}}{{/baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/isContainer}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}}
|
||||
{{^isPathParam}} **{{paramName}}** | {{#isContainer}}{{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**map[string]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/isContainer}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}}
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Name | Type | Description | Notes
|
||||
**{{classname}}Interface** | **interface { {{#discriminator}}{{propertyGetter}}() {{propertyType}}{{/discriminator}} }** | An interface that can hold any of the proper implementing types |
|
||||
{{/vendorExtensions.x-is-one-of-interface}}
|
||||
{{^vendorExtensions.x-is-one-of-interface}}
|
||||
{{#vars}}**{{name}}** | {{^required}}Pointer to {{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{#vars}}**{{name}}** | {{^required}}Pointer to {{/required}}{{#isContainer}}{{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{dataType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**map[string]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}{{^isDateTime}}[{{/isDateTime}}{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}{{^isDateTime}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isDateTime}}{{/isFile}}{{/isPrimitiveType}}{{/isContainer}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
{{/vendorExtensions.x-is-one-of-interface}}
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ Name | Type | Description | Notes
|
||||
**MapNumber** | Pointer to **map[string]float32** | | [optional]
|
||||
**MapInteger** | Pointer to **map[string]int32** | | [optional]
|
||||
**MapBoolean** | Pointer to **map[string]bool** | | [optional]
|
||||
**MapArrayInteger** | Pointer to [**map[string][]int32**](array.md) | | [optional]
|
||||
**MapArrayAnytype** | Pointer to [**map[string][]map[string]interface{}**](array.md) | | [optional]
|
||||
**MapMapString** | Pointer to [**map[string]map[string]string**](map.md) | | [optional]
|
||||
**MapMapAnytype** | Pointer to [**map[string]map[string]map[string]interface{}**](map.md) | | [optional]
|
||||
**MapArrayInteger** | Pointer to **map[string][]int32** | | [optional]
|
||||
**MapArrayAnytype** | Pointer to **map[string][]map[string]interface{}** | | [optional]
|
||||
**MapMapString** | Pointer to **map[string]map[string]string** | | [optional]
|
||||
**MapMapAnytype** | Pointer to **map[string]map[string]map[string]interface{}** | | [optional]
|
||||
**Anytype1** | Pointer to **map[string]interface{}** | | [optional]
|
||||
**Anytype2** | Pointer to **map[string]interface{}** | | [optional]
|
||||
**Anytype3** | Pointer to **map[string]interface{}** | | [optional]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ArrayArrayNumber** | Pointer to [**[][]float32**](array.md) | | [optional]
|
||||
**ArrayArrayNumber** | Pointer to **[][]float32** | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ArrayOfString** | Pointer to **[]string** | | [optional]
|
||||
**ArrayArrayOfInteger** | Pointer to [**[][]int64**](array.md) | | [optional]
|
||||
**ArrayArrayOfModel** | Pointer to [**[][]ReadOnlyFirst**](array.md) | | [optional]
|
||||
**ArrayArrayOfInteger** | Pointer to **[][]int64** | | [optional]
|
||||
**ArrayArrayOfModel** | Pointer to [**[][]ReadOnlyFirst**]([]ReadOnlyFirst.md) | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ Name | Type | Description | Notes
|
||||
**Double** | Pointer to **float64** | | [optional]
|
||||
**String** | Pointer to **string** | | [optional]
|
||||
**Byte** | **string** | |
|
||||
**Binary** | Pointer to [***os.File**](*os.File.md) | | [optional]
|
||||
**Binary** | Pointer to ***os.File** | | [optional]
|
||||
**Date** | **string** | |
|
||||
**DateTime** | Pointer to [**time.Time**](time.Time.md) | | [optional]
|
||||
**DateTime** | Pointer to **time.Time** | | [optional]
|
||||
**Uuid** | Pointer to **string** | | [optional]
|
||||
**Password** | **string** | |
|
||||
**BigDecimal** | Pointer to **float64** | | [optional]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**MapMapOfString** | Pointer to [**map[string]map[string]string**](map.md) | | [optional]
|
||||
**MapMapOfString** | Pointer to **map[string]map[string]string** | | [optional]
|
||||
**MapOfEnumString** | Pointer to **map[string]string** | | [optional]
|
||||
**DirectMap** | Pointer to **map[string]bool** | | [optional]
|
||||
**IndirectMap** | Pointer to **map[string]bool** | | [optional]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Uuid** | Pointer to **string** | | [optional]
|
||||
**DateTime** | Pointer to [**time.Time**](time.Time.md) | | [optional]
|
||||
**DateTime** | Pointer to **time.Time** | | [optional]
|
||||
**Map** | Pointer to [**map[string]Animal**](Animal.md) | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
|
||||
**Id** | Pointer to **int64** | | [optional]
|
||||
**PetId** | Pointer to **int64** | | [optional]
|
||||
**Quantity** | Pointer to **int32** | | [optional]
|
||||
**ShipDate** | Pointer to [**time.Time**](time.Time.md) | | [optional]
|
||||
**ShipDate** | Pointer to **time.Time** | | [optional]
|
||||
**Status** | Pointer to **string** | Order Status | [optional]
|
||||
**Complete** | Pointer to **bool** | | [optional] [default to false]
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**MapProperty** | Pointer to **map[string]string** | | [optional]
|
||||
**MapOfMapProperty** | Pointer to [**map[string]map[string]string**](map.md) | | [optional]
|
||||
**MapOfMapProperty** | Pointer to **map[string]map[string]string** | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ArrayArrayNumber** | Pointer to [**[][]float32**](array.md) | | [optional]
|
||||
**ArrayArrayNumber** | Pointer to **[][]float32** | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ArrayOfString** | Pointer to **[]string** | | [optional]
|
||||
**ArrayArrayOfInteger** | Pointer to [**[][]int64**](array.md) | | [optional]
|
||||
**ArrayArrayOfModel** | Pointer to [**[][]ReadOnlyFirst**](array.md) | | [optional]
|
||||
**ArrayArrayOfInteger** | Pointer to **[][]int64** | | [optional]
|
||||
**ArrayArrayOfModel** | Pointer to [**[][]ReadOnlyFirst**]([]ReadOnlyFirst.md) | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ Name | Type | Description | Notes
|
||||
**Double** | Pointer to **float64** | | [optional]
|
||||
**String** | Pointer to **string** | | [optional]
|
||||
**Byte** | **string** | |
|
||||
**Binary** | Pointer to [***os.File**](*os.File.md) | | [optional]
|
||||
**Binary** | Pointer to ***os.File** | | [optional]
|
||||
**Date** | **string** | |
|
||||
**DateTime** | Pointer to [**time.Time**](time.Time.md) | | [optional]
|
||||
**DateTime** | Pointer to **time.Time** | | [optional]
|
||||
**Uuid** | Pointer to **string** | | [optional]
|
||||
**Password** | **string** | |
|
||||
**PatternWithDigits** | Pointer to **string** | A string that is a 10 digit number. Can have leading zeros. | [optional]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**AdditionalMetadata** | Pointer to **string** | Additional data to pass to server | [optional]
|
||||
**File** | Pointer to [***os.File**](*os.File.md) | file to upload | [optional]
|
||||
**File** | Pointer to ***os.File** | file to upload | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ Name | Type | Description | Notes
|
||||
**String** | Pointer to **string** | None | [optional]
|
||||
**PatternWithoutDelimiter** | **string** | None |
|
||||
**Byte** | **string** | None |
|
||||
**Binary** | Pointer to [***os.File**](*os.File.md) | None | [optional]
|
||||
**Binary** | Pointer to ***os.File** | None | [optional]
|
||||
**Date** | Pointer to **string** | None | [optional]
|
||||
**DateTime** | Pointer to [**time.Time**](time.Time.md) | None | [optional]
|
||||
**DateTime** | Pointer to **time.Time** | None | [optional]
|
||||
**Password** | Pointer to **string** | None | [optional]
|
||||
**Callback** | Pointer to **string** | None | [optional]
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**AdditionalMetadata** | Pointer to **string** | Additional data to pass to server | [optional]
|
||||
**RequiredFile** | [***os.File**](*os.File.md) | file to upload |
|
||||
**RequiredFile** | ***os.File** | file to upload |
|
||||
|
||||
## Methods
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**MapMapOfString** | Pointer to [**map[string]map[string]string**](map.md) | | [optional]
|
||||
**MapMapOfString** | Pointer to **map[string]map[string]string** | | [optional]
|
||||
**MapOfEnumString** | Pointer to **map[string]string** | | [optional]
|
||||
**DirectMap** | Pointer to **map[string]bool** | | [optional]
|
||||
**IndirectMap** | Pointer to **map[string]bool** | | [optional]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Uuid** | Pointer to **string** | | [optional]
|
||||
**DateTime** | Pointer to [**time.Time**](time.Time.md) | | [optional]
|
||||
**DateTime** | Pointer to **time.Time** | | [optional]
|
||||
**Map** | Pointer to [**map[string]Animal**](Animal.md) | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -9,7 +9,7 @@ Name | Type | Description | Notes
|
||||
**BooleanProp** | Pointer to **NullableBool** | | [optional]
|
||||
**StringProp** | Pointer to **NullableString** | | [optional]
|
||||
**DateProp** | Pointer to **NullableString** | | [optional]
|
||||
**DatetimeProp** | Pointer to [**NullableTime**](time.Time.md) | | [optional]
|
||||
**DatetimeProp** | Pointer to **NullableTime** | | [optional]
|
||||
**ArrayNullableProp** | Pointer to **[]map[string]interface{}** | | [optional]
|
||||
**ArrayAndItemsNullableProp** | Pointer to **[]map[string]interface{}** | | [optional]
|
||||
**ArrayItemsNullable** | Pointer to **[]map[string]interface{}** | | [optional]
|
||||
|
||||
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
|
||||
**Id** | Pointer to **int64** | | [optional]
|
||||
**PetId** | Pointer to **int64** | | [optional]
|
||||
**Quantity** | Pointer to **int32** | | [optional]
|
||||
**ShipDate** | Pointer to [**time.Time**](time.Time.md) | | [optional]
|
||||
**ShipDate** | Pointer to **time.Time** | | [optional]
|
||||
**Status** | Pointer to **string** | Order Status | [optional]
|
||||
**Complete** | Pointer to **bool** | | [optional] [default to false]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user