Fix a few issues with go examples generation (#7873)

* Fix a few issues with go examples generation

This fixes a bunch of issues seen when generating go examples, namely
 - Numbers aren't casted to the right type
 - The time import is missing
 - Enums are treated as regular models

* Rebuild more samples

* Use examples properly

* Handle multiple instances in the same doc

* Fix wrong array closure

* Handle model arrays

* Fix file and enum namespace

* Regenerate samples

* Handle maps of complex types

* Handle oneOf

* Fix padding

* Fix enum doc

* Removes links to basic types in arrays

* Remove links to basic types in maps

* Fix enum links

* Minor indent fix

* Handle review comments
This commit is contained in:
Thomas Hervé 2020-11-12 16:36:40 +01:00 committed by GitHub
parent 3b84e8bb55
commit 777031f24f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 194 additions and 122 deletions

View File

@ -448,13 +448,21 @@ public class GoClientCodegen extends AbstractGoCodegen {
for (CodegenParameter p : op.allParams) { for (CodegenParameter p : op.allParams) {
p.vendorExtensions.put("x-go-example", constructExampleCode(p, modelMaps, processedModelMaps)); p.vendorExtensions.put("x-go-example", constructExampleCode(p, modelMaps, processedModelMaps));
} }
processedModelMaps.clear();
} }
processedModelMaps.clear();
for (CodegenOperation operation : operationList) { for (CodegenOperation operation : operationList) {
boolean needTimeImport = false;
for (CodegenParameter cp : operation.allParams) { for (CodegenParameter cp : operation.allParams) {
cp.vendorExtensions.put("x-go-example", constructExampleCode(cp, modelMaps, processedModelMaps)); cp.vendorExtensions.put("x-go-example", constructExampleCode(cp, modelMaps, processedModelMaps));
if (cp.isDateTime || cp.isDate) { // datetime or date
needTimeImport = true;
}
} }
if (needTimeImport) {
operation.vendorExtensions.put("x-go-import", " \"time\"");
}
processedModelMaps.clear();
} }
return objs; return objs;
@ -462,12 +470,22 @@ public class GoClientCodegen extends AbstractGoCodegen {
private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) { private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
if (codegenParameter.isArray) { // array if (codegenParameter.isArray) { // array
return codegenParameter.dataType + "{" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}"; String prefix = codegenParameter.dataType;
String dataType = StringUtils.removeStart(codegenParameter.dataType, "[]");
if (modelMaps.containsKey(dataType)) {
prefix = "[]" + goImportAlias + "." + dataType;
}
return prefix + "{" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
} else if (codegenParameter.isMap) { } else if (codegenParameter.isMap) {
return codegenParameter.dataType + "{ \"key\": " + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}"; String prefix = codegenParameter.dataType;
String dataType = StringUtils.removeStart(codegenParameter.dataType, "map[string][]");
if (modelMaps.containsKey(dataType)) {
prefix = "map[string][]" + goImportAlias + "." + dataType;
}
return prefix + "{\"key\": " + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + "}";
} else if (codegenParameter.isPrimitiveType) { // primitive type } else if (codegenParameter.isPrimitiveType) { // primitive type
if (codegenParameter.isString) { if (codegenParameter.isString) {
if (StringUtils.isEmpty(codegenParameter.example)) { if (!StringUtils.isEmpty(codegenParameter.example) && codegenParameter.example != "null") {
return "\"" + codegenParameter.example + "\""; return "\"" + codegenParameter.example + "\"";
} else { } else {
return "\"" + codegenParameter.paramName + "_example\""; return "\"" + codegenParameter.paramName + "_example\"";
@ -482,11 +500,13 @@ public class GoClientCodegen extends AbstractGoCodegen {
return "\"https://example.com\""; return "\"https://example.com\"";
} else if (codegenParameter.isDateTime || codegenParameter.isDate) { // datetime or date } else if (codegenParameter.isDateTime || codegenParameter.isDate) { // datetime or date
return "time.Now()"; return "time.Now()";
} else if (codegenParameter.isFile) {
return "os.NewFile(1234, \"some_file\")";
} else { // numeric } else { // numeric
if (StringUtils.isEmpty(codegenParameter.example)) { if (!StringUtils.isEmpty(codegenParameter.example) && codegenParameter.example != "null") {
return codegenParameter.example; return codegenParameter.dataType + "(" + codegenParameter.example + ")";
} else { } else {
return "987"; return codegenParameter.dataType + "(987)";
} }
} }
} else { // model } else { // model
@ -502,12 +522,22 @@ public class GoClientCodegen extends AbstractGoCodegen {
private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) { private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
if (codegenProperty.isArray) { // array if (codegenProperty.isArray) { // array
return codegenProperty.dataType + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + ")"; String prefix = codegenProperty.dataType;
String dataType = StringUtils.removeStart(codegenProperty.dataType, "[]");
if (modelMaps.containsKey(dataType)) {
prefix = "[]" + goImportAlias + "." + dataType;
}
return prefix + "{" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
} else if (codegenProperty.isMap) { // map } else if (codegenProperty.isMap) { // map
return codegenProperty.dataType + "{ \"key\": " + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}"; String prefix = codegenProperty.dataType;
String dataType = StringUtils.removeStart(codegenProperty.dataType, "map[string][]");
if (modelMaps.containsKey(dataType)) {
prefix = "map[string][]" + goImportAlias + "." + dataType;
}
return prefix + "{\"key\": " + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + "}";
} else if (codegenProperty.isPrimitiveType) { // primitive type } else if (codegenProperty.isPrimitiveType) { // primitive type
if (codegenProperty.isString) { if (codegenProperty.isString) {
if (StringUtils.isEmpty(codegenProperty.example)) { if (!StringUtils.isEmpty(codegenProperty.example) && codegenProperty.example != "null") {
return "\"" + codegenProperty.example + "\""; return "\"" + codegenProperty.example + "\"";
} else { } else {
return "\"" + codegenProperty.name + "_example\""; return "\"" + codegenProperty.name + "_example\"";
@ -524,17 +554,13 @@ public class GoClientCodegen extends AbstractGoCodegen {
return "time.Now()"; return "time.Now()";
} else { // numeric } else { // numeric
String example; String example;
if (StringUtils.isEmpty(codegenProperty.example)) { if (!StringUtils.isEmpty(codegenProperty.example) && codegenProperty.example != "null") {
example = codegenProperty.example; example = codegenProperty.example;
} else { } else {
example = "123"; example = "123";
} }
if (codegenProperty.isLong) { return codegenProperty.dataType + "(" + example + ")";
return "int64(" + example + ")";
} else {
return example;
}
} }
} else { } else {
// look up the model // look up the model
@ -548,8 +574,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
} }
private String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) { private String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
String example;
// break infinite recursion. Return, in case a model is already processed in the current context. // break infinite recursion. Return, in case a model is already processed in the current context.
String model = codegenModel.name; String model = codegenModel.name;
if (processedModelMap.containsKey(model)) { if (processedModelMap.containsKey(model)) {
@ -561,6 +585,14 @@ public class GoClientCodegen extends AbstractGoCodegen {
} else { } else {
throw new RuntimeException("Invalid count when constructing example: " + count); throw new RuntimeException("Invalid count when constructing example: " + count);
} }
} else if (codegenModel.isEnum) {
Map<String, Object> allowableValues = codegenModel.allowableValues;
List<Object> values = (List<Object>) allowableValues.get("values");
return goImportAlias + "." + model + "(\"" + String.valueOf(values.get(0)) + "\")";
} else if (codegenModel.oneOf != null && !codegenModel.oneOf.isEmpty()) {
String subModel = (String) codegenModel.oneOf.toArray()[0];
String oneOf = constructExampleCode(modelMaps.get(subModel), modelMaps, processedModelMap).substring(1);
return goImportAlias + "." + model + "{" + subModel + ": " + oneOf + "}";
} else { } else {
processedModelMap.put(model, 1); processedModelMap.put(model, 1);
} }
@ -569,6 +601,6 @@ public class GoClientCodegen extends AbstractGoCodegen {
for (CodegenProperty codegenProperty : codegenModel.requiredVars) { for (CodegenProperty codegenProperty : codegenModel.requiredVars) {
propertyExamples.add(constructExampleCode(codegenProperty, modelMaps, processedModelMap)); propertyExamples.add(constructExampleCode(codegenProperty, modelMaps, processedModelMap));
} }
return "*" + goImportAlias + ".New" + codegenModel.name + "(" + StringUtils.join(propertyExamples, ", ") + ")"; return "*" + goImportAlias + ".New" + model + "(" + StringUtils.join(propertyExamples, ", ") + ")";
} }
} }

View File

@ -29,6 +29,9 @@ import (
"context" "context"
"fmt" "fmt"
"os" "os"
{{#vendorExtensions.x-go-import}}
{{{vendorExtensions.x-go-import}}}
{{/vendorExtensions.x-go-import}}
{{goImportAlias}} "./openapi" {{goImportAlias}} "./openapi"
) )
@ -66,7 +69,7 @@ Other parameters are passed through a pointer to a api{{{nickname}}}Request stru
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}} ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
{{^isPathParam}} **{{paramName}}** | {{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/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}}
### Return type ### Return type

View File

@ -1,5 +1,6 @@
{{#models}}{{#model}}# {{classname}} {{#models}}{{#model}}# {{classname}}
{{^isEnum}}
## Properties ## Properties
Name | Type | Description | Notes Name | Type | Description | Notes
@ -12,7 +13,6 @@ Name | Type | Description | Notes
{{/vars}} {{/vars}}
{{/vendorExtensions.x-is-one-of-interface}} {{/vendorExtensions.x-is-one-of-interface}}
{{^isEnum}}
## Methods ## Methods
{{^vendorExtensions.x-is-one-of-interface}} {{^vendorExtensions.x-is-one-of-interface}}
@ -84,6 +84,13 @@ Convenience method to wrap this instance of {{classname}} in {{{.}}}
{{/vendorExtensions.x-implements}} {{/vendorExtensions.x-implements}}
{{/vendorExtensions.x-is-one-of-interface}} {{/vendorExtensions.x-is-one-of-interface}}
{{/isEnum}} {{/isEnum}}
{{#isEnum}}
## Enum
{{#allowableValues}}{{#enumVars}}
* `{{name}}` (value: `{{{value}}}`)
{{/enumVars}}{{/allowableValues}}
{{/isEnum}}
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -1,9 +1,13 @@
# EnumClass # EnumClass
## Properties ## Enum
Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- * `ABC` (value: `"_abc"`)
* `EFG` (value: `"-efg"`)
* `XYZ` (value: `"(xyz)"`)
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -238,7 +238,7 @@ import (
) )
func main() { func main() {
body := 987 // float32 | Input number as post body (optional) body := float32(8.14) // float32 | Input number as post body (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -560,20 +560,21 @@ import (
"context" "context"
"fmt" "fmt"
"os" "os"
"time"
openapiclient "./openapi" openapiclient "./openapi"
) )
func main() { func main() {
number := 987 // float32 | None number := float32(8.14) // float32 | None
double := 987 // float64 | None double := float64(1.2) // float64 | None
patternWithoutDelimiter := "patternWithoutDelimiter_example" // string | None patternWithoutDelimiter := "patternWithoutDelimiter_example" // string | None
byte_ := 987 // string | None byte_ := string(BYTE_ARRAY_DATA_HERE) // string | None
integer := 987 // int32 | None (optional) integer := int32(56) // int32 | None (optional)
int32_ := 987 // int32 | None (optional) int32_ := int32(56) // int32 | None (optional)
int64_ := 987 // int64 | None (optional) int64_ := int64(789) // int64 | None (optional)
float := 987 // float32 | None (optional) float := float32(3.4) // float32 | None (optional)
string_ := "string__example" // string | None (optional) string_ := "string__example" // string | None (optional)
binary := 987 // *os.File | None (optional) binary := os.NewFile(1234, "some_file") // *os.File | None (optional)
date := time.Now() // string | None (optional) date := time.Now() // string | None (optional)
dateTime := time.Now() // time.Time | None (optional) dateTime := time.Now() // time.Time | None (optional)
password := "password_example" // string | None (optional) password := "password_example" // string | None (optional)
@ -658,8 +659,8 @@ func main() {
enumHeaderString := "enumHeaderString_example" // string | Header parameter enum test (string) (optional) (default to "-efg") enumHeaderString := "enumHeaderString_example" // string | Header parameter enum test (string) (optional) (default to "-efg")
enumQueryStringArray := []string{"EnumQueryStringArray_example"} // []string | Query parameter enum test (string array) (optional) enumQueryStringArray := []string{"EnumQueryStringArray_example"} // []string | Query parameter enum test (string array) (optional)
enumQueryString := "enumQueryString_example" // string | Query parameter enum test (string) (optional) (default to "-efg") enumQueryString := "enumQueryString_example" // string | Query parameter enum test (string) (optional) (default to "-efg")
enumQueryInteger := 987 // int32 | Query parameter enum test (double) (optional) enumQueryInteger := int32(56) // int32 | Query parameter enum test (double) (optional)
enumQueryDouble := 987 // float64 | Query parameter enum test (double) (optional) enumQueryDouble := float64(1.2) // float64 | Query parameter enum test (double) (optional)
enumFormStringArray := []string{"Inner_example"} // []string | Form parameter enum test (string array) (optional) (default to "$") enumFormStringArray := []string{"Inner_example"} // []string | Form parameter enum test (string array) (optional) (default to "$")
enumFormString := "enumFormString_example" // string | Form parameter enum test (string) (optional) (default to "-efg") enumFormString := "enumFormString_example" // string | Form parameter enum test (string) (optional) (default to "-efg")
@ -684,13 +685,13 @@ Other parameters are passed through a pointer to a apiTestEnumParametersRequest
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**enumHeaderStringArray** | [**[]string**](string.md) | Header parameter enum test (string array) | **enumHeaderStringArray** | **[]string** | Header parameter enum test (string array) |
**enumHeaderString** | **string** | Header parameter enum test (string) | [default to &quot;-efg&quot;] **enumHeaderString** | **string** | Header parameter enum test (string) | [default to &quot;-efg&quot;]
**enumQueryStringArray** | [**[]string**](string.md) | Query parameter enum test (string array) | **enumQueryStringArray** | **[]string** | Query parameter enum test (string array) |
**enumQueryString** | **string** | Query parameter enum test (string) | [default to &quot;-efg&quot;] **enumQueryString** | **string** | Query parameter enum test (string) | [default to &quot;-efg&quot;]
**enumQueryInteger** | **int32** | Query parameter enum test (double) | **enumQueryInteger** | **int32** | Query parameter enum test (double) |
**enumQueryDouble** | **float64** | Query parameter enum test (double) | **enumQueryDouble** | **float64** | Query parameter enum test (double) |
**enumFormStringArray** | [**[]string**](string.md) | Form parameter enum test (string array) | [default to &quot;$&quot;] **enumFormStringArray** | **[]string** | Form parameter enum test (string array) | [default to &quot;$&quot;]
**enumFormString** | **string** | Form parameter enum test (string) | [default to &quot;-efg&quot;] **enumFormString** | **string** | Form parameter enum test (string) | [default to &quot;-efg&quot;]
### Return type ### Return type
@ -732,12 +733,12 @@ import (
) )
func main() { func main() {
requiredStringGroup := 987 // int32 | Required String in group parameters requiredStringGroup := int32(56) // int32 | Required String in group parameters
requiredBooleanGroup := true // bool | Required Boolean in group parameters requiredBooleanGroup := true // bool | Required Boolean in group parameters
requiredInt64Group := 987 // int64 | Required Integer in group parameters requiredInt64Group := int64(789) // int64 | Required Integer in group parameters
stringGroup := 987 // int32 | String in group parameters (optional) stringGroup := int32(56) // int32 | String in group parameters (optional)
booleanGroup := true // bool | Boolean in group parameters (optional) booleanGroup := true // bool | Boolean in group parameters (optional)
int64Group := 987 // int64 | Integer in group parameters (optional) int64Group := int64(789) // int64 | Integer in group parameters (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -804,7 +805,7 @@ import (
) )
func main() { func main() {
param := map[string]string{ "key": "Inner_example"} // map[string]string | request body param := map[string]string{"key": "Inner_example"} // map[string]string | request body
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -827,7 +828,7 @@ Other parameters are passed through a pointer to a apiTestInlineAdditionalProper
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**param** | [**map[string]string**](string.md) | request body | **param** | **map[string]string** | request body |
### Return type ### Return type
@ -959,11 +960,11 @@ Other parameters are passed through a pointer to a apiTestQueryParameterCollecti
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pipe** | [**[]string**](string.md) | | **pipe** | **[]string** | |
**ioutil** | [**[]string**](string.md) | | **ioutil** | **[]string** | |
**http** | [**[]string**](string.md) | | **http** | **[]string** | |
**url** | [**[]string**](string.md) | | **url** | **[]string** | |
**context** | [**[]string**](string.md) | | **context** | **[]string** | |
### Return type ### Return type

View File

@ -1,9 +1,13 @@
# OuterEnum # OuterEnum
## Properties ## Enum
Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- * `PLACED` (value: `"placed"`)
* `APPROVED` (value: `"approved"`)
* `DELIVERED` (value: `"delivered"`)
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -35,7 +35,7 @@ import (
) )
func main() { func main() {
body := *openapiclient.NewPet("Name_example", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store body := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example"}) // Pet | Pet object that needs to be added to the store
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -97,7 +97,7 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | Pet id to delete petId := int64(789) // int64 | Pet id to delete
apiKey := "apiKey_example" // string | (optional) apiKey := "apiKey_example" // string | (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
@ -192,7 +192,7 @@ Other parameters are passed through a pointer to a apiFindPetsByStatusRequest st
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**status** | [**[]string**](string.md) | Status values that need to be considered for filter | **status** | **[]string** | Status values that need to be considered for filter |
### Return type ### Return type
@ -258,7 +258,7 @@ Other parameters are passed through a pointer to a apiFindPetsByTagsRequest stru
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**tags** | [**[]string**](string.md) | Tags to filter by | **tags** | **[]string** | Tags to filter by |
### Return type ### Return type
@ -299,7 +299,7 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | ID of pet to return petId := int64(789) // int64 | ID of pet to return
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -367,7 +367,7 @@ import (
) )
func main() { func main() {
body := *openapiclient.NewPet("Name_example", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store body := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example"}) // Pet | Pet object that needs to be added to the store
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -429,7 +429,7 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | ID of pet that needs to be updated petId := int64(789) // int64 | ID of pet that needs to be updated
name := "name_example" // string | Updated name of the pet (optional) name := "name_example" // string | Updated name of the pet (optional)
status := "status_example" // string | Updated status of the pet (optional) status := "status_example" // string | Updated status of the pet (optional)
@ -499,9 +499,9 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | ID of pet to update petId := int64(789) // int64 | ID of pet to update
additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional) additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
file := 987 // *os.File | file to upload (optional) file := os.NewFile(1234, "some_file") // *os.File | file to upload (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -571,8 +571,8 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | ID of pet to update petId := int64(789) // int64 | ID of pet to update
requiredFile := 987 // *os.File | file to upload requiredFile := os.NewFile(1234, "some_file") // *os.File | file to upload
additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional) additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()

View File

@ -161,7 +161,7 @@ import (
) )
func main() { func main() {
orderId := 987 // int64 | ID of pet that needs to be fetched orderId := int64(789) // int64 | ID of pet that needs to be fetched
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)

View File

@ -98,7 +98,7 @@ import (
) )
func main() { func main() {
body := []User{*openapiclient.NewUser()} // []User | List of user object body := []openapiclient.User{*openapiclient.NewUser()} // []User | List of user object
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -160,7 +160,7 @@ import (
) )
func main() { func main() {
body := []User{} // []User | List of user object body := []openapiclient.User{*openapiclient.NewUser()} // []User | List of user object
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -484,7 +484,7 @@ import (
func main() { func main() {
username := "username_example" // string | name that need to be deleted username := "username_example" // string | name that need to be deleted
body := // User | Updated user object body := *openapiclient.NewUser() // User | Updated user object
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)

View File

@ -1,9 +1,13 @@
# EnumClass # EnumClass
## Properties ## Enum
Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- * `ABC` (value: `"_abc"`)
* `EFG` (value: `"-efg"`)
* `XYZ` (value: `"(xyz)"`)
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -233,7 +233,7 @@ import (
) )
func main() { func main() {
body := 987 // float32 | Input number as post body (optional) body := float32(8.14) // float32 | Input number as post body (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -555,20 +555,21 @@ import (
"context" "context"
"fmt" "fmt"
"os" "os"
"time"
openapiclient "./openapi" openapiclient "./openapi"
) )
func main() { func main() {
number := 987 // float32 | None number := float32(8.14) // float32 | None
double := 987 // float64 | None double := float64(1.2) // float64 | None
patternWithoutDelimiter := "patternWithoutDelimiter_example" // string | None patternWithoutDelimiter := "patternWithoutDelimiter_example" // string | None
byte_ := 987 // string | None byte_ := string(BYTE_ARRAY_DATA_HERE) // string | None
integer := 987 // int32 | None (optional) integer := int32(56) // int32 | None (optional)
int32_ := 987 // int32 | None (optional) int32_ := int32(56) // int32 | None (optional)
int64_ := 987 // int64 | None (optional) int64_ := int64(789) // int64 | None (optional)
float := 987 // float32 | None (optional) float := float32(3.4) // float32 | None (optional)
string_ := "string__example" // string | None (optional) string_ := "string__example" // string | None (optional)
binary := 987 // *os.File | None (optional) binary := os.NewFile(1234, "some_file") // *os.File | None (optional)
date := time.Now() // string | None (optional) date := time.Now() // string | None (optional)
dateTime := time.Now() // time.Time | None (optional) dateTime := time.Now() // time.Time | None (optional)
password := "password_example" // string | None (optional) password := "password_example" // string | None (optional)
@ -653,8 +654,8 @@ func main() {
enumHeaderString := "enumHeaderString_example" // string | Header parameter enum test (string) (optional) (default to "-efg") enumHeaderString := "enumHeaderString_example" // string | Header parameter enum test (string) (optional) (default to "-efg")
enumQueryStringArray := []string{"EnumQueryStringArray_example"} // []string | Query parameter enum test (string array) (optional) enumQueryStringArray := []string{"EnumQueryStringArray_example"} // []string | Query parameter enum test (string array) (optional)
enumQueryString := "enumQueryString_example" // string | Query parameter enum test (string) (optional) (default to "-efg") enumQueryString := "enumQueryString_example" // string | Query parameter enum test (string) (optional) (default to "-efg")
enumQueryInteger := 987 // int32 | Query parameter enum test (double) (optional) enumQueryInteger := int32(56) // int32 | Query parameter enum test (double) (optional)
enumQueryDouble := 987 // float64 | Query parameter enum test (double) (optional) enumQueryDouble := float64(1.2) // float64 | Query parameter enum test (double) (optional)
enumFormStringArray := []string{"Inner_example"} // []string | Form parameter enum test (string array) (optional) (default to "$") enumFormStringArray := []string{"Inner_example"} // []string | Form parameter enum test (string array) (optional) (default to "$")
enumFormString := "enumFormString_example" // string | Form parameter enum test (string) (optional) (default to "-efg") enumFormString := "enumFormString_example" // string | Form parameter enum test (string) (optional) (default to "-efg")
@ -679,13 +680,13 @@ Other parameters are passed through a pointer to a apiTestEnumParametersRequest
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**enumHeaderStringArray** | [**[]string**](string.md) | Header parameter enum test (string array) | **enumHeaderStringArray** | **[]string** | Header parameter enum test (string array) |
**enumHeaderString** | **string** | Header parameter enum test (string) | [default to &quot;-efg&quot;] **enumHeaderString** | **string** | Header parameter enum test (string) | [default to &quot;-efg&quot;]
**enumQueryStringArray** | [**[]string**](string.md) | Query parameter enum test (string array) | **enumQueryStringArray** | **[]string** | Query parameter enum test (string array) |
**enumQueryString** | **string** | Query parameter enum test (string) | [default to &quot;-efg&quot;] **enumQueryString** | **string** | Query parameter enum test (string) | [default to &quot;-efg&quot;]
**enumQueryInteger** | **int32** | Query parameter enum test (double) | **enumQueryInteger** | **int32** | Query parameter enum test (double) |
**enumQueryDouble** | **float64** | Query parameter enum test (double) | **enumQueryDouble** | **float64** | Query parameter enum test (double) |
**enumFormStringArray** | [**[]string**](string.md) | Form parameter enum test (string array) | [default to &quot;$&quot;] **enumFormStringArray** | **[]string** | Form parameter enum test (string array) | [default to &quot;$&quot;]
**enumFormString** | **string** | Form parameter enum test (string) | [default to &quot;-efg&quot;] **enumFormString** | **string** | Form parameter enum test (string) | [default to &quot;-efg&quot;]
### Return type ### Return type
@ -727,12 +728,12 @@ import (
) )
func main() { func main() {
requiredStringGroup := 987 // int32 | Required String in group parameters requiredStringGroup := int32(56) // int32 | Required String in group parameters
requiredBooleanGroup := true // bool | Required Boolean in group parameters requiredBooleanGroup := true // bool | Required Boolean in group parameters
requiredInt64Group := 987 // int64 | Required Integer in group parameters requiredInt64Group := int64(789) // int64 | Required Integer in group parameters
stringGroup := 987 // int32 | String in group parameters (optional) stringGroup := int32(56) // int32 | String in group parameters (optional)
booleanGroup := true // bool | Boolean in group parameters (optional) booleanGroup := true // bool | Boolean in group parameters (optional)
int64Group := 987 // int64 | Integer in group parameters (optional) int64Group := int64(789) // int64 | Integer in group parameters (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -799,7 +800,7 @@ import (
) )
func main() { func main() {
requestBody := map[string]string{ "key": "Inner_example"} // map[string]string | request body requestBody := map[string]string{"key": "Inner_example"} // map[string]string | request body
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -822,7 +823,7 @@ Other parameters are passed through a pointer to a apiTestInlineAdditionalProper
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**requestBody** | [**map[string]string**](string.md) | request body | **requestBody** | **map[string]string** | request body |
### Return type ### Return type
@ -954,11 +955,11 @@ Other parameters are passed through a pointer to a apiTestQueryParameterCollecti
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pipe** | [**[]string**](string.md) | | **pipe** | **[]string** | |
**ioutil** | [**[]string**](string.md) | | **ioutil** | **[]string** | |
**http** | [**[]string**](string.md) | | **http** | **[]string** | |
**url** | [**[]string**](string.md) | | **url** | **[]string** | |
**context** | [**[]string**](string.md) | | **context** | **[]string** | |
### Return type ### Return type

View File

@ -1,9 +1,13 @@
# OuterEnum # OuterEnum
## Properties ## Enum
Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- * `PLACED` (value: `"placed"`)
* `APPROVED` (value: `"approved"`)
* `DELIVERED` (value: `"delivered"`)
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -1,9 +1,13 @@
# OuterEnumDefaultValue # OuterEnumDefaultValue
## Properties ## Enum
Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- * `PLACED` (value: `"placed"`)
* `APPROVED` (value: `"approved"`)
* `DELIVERED` (value: `"delivered"`)
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -1,9 +1,13 @@
# OuterEnumInteger # OuterEnumInteger
## Properties ## Enum
Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- * `_0` (value: `0`)
* `_1` (value: `1`)
* `_2` (value: `2`)
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -1,9 +1,13 @@
# OuterEnumIntegerDefaultValue # OuterEnumIntegerDefaultValue
## Properties ## Enum
Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- * `_0` (value: `0`)
* `_1` (value: `1`)
* `_2` (value: `2`)
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -35,7 +35,7 @@ import (
) )
func main() { func main() {
pet := *openapiclient.NewPet("Name_example", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store pet := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example"}) // Pet | Pet object that needs to be added to the store
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -97,7 +97,7 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | Pet id to delete petId := int64(789) // int64 | Pet id to delete
apiKey := "apiKey_example" // string | (optional) apiKey := "apiKey_example" // string | (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
@ -192,7 +192,7 @@ Other parameters are passed through a pointer to a apiFindPetsByStatusRequest st
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**status** | [**[]string**](string.md) | Status values that need to be considered for filter | **status** | **[]string** | Status values that need to be considered for filter |
### Return type ### Return type
@ -258,7 +258,7 @@ Other parameters are passed through a pointer to a apiFindPetsByTagsRequest stru
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**tags** | [**[]string**](string.md) | Tags to filter by | **tags** | **[]string** | Tags to filter by |
### Return type ### Return type
@ -299,7 +299,7 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | ID of pet to return petId := int64(789) // int64 | ID of pet to return
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -367,7 +367,7 @@ import (
) )
func main() { func main() {
pet := *openapiclient.NewPet("Name_example", []string{"PhotoUrls_example")) // Pet | Pet object that needs to be added to the store pet := *openapiclient.NewPet("doggie", []string{"PhotoUrls_example"}) // Pet | Pet object that needs to be added to the store
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -429,7 +429,7 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | ID of pet that needs to be updated petId := int64(789) // int64 | ID of pet that needs to be updated
name := "name_example" // string | Updated name of the pet (optional) name := "name_example" // string | Updated name of the pet (optional)
status := "status_example" // string | Updated status of the pet (optional) status := "status_example" // string | Updated status of the pet (optional)
@ -499,9 +499,9 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | ID of pet to update petId := int64(789) // int64 | ID of pet to update
additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional) additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
file := 987 // *os.File | file to upload (optional) file := os.NewFile(1234, "some_file") // *os.File | file to upload (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -571,8 +571,8 @@ import (
) )
func main() { func main() {
petId := 987 // int64 | ID of pet to update petId := int64(789) // int64 | ID of pet to update
requiredFile := 987 // *os.File | file to upload requiredFile := os.NewFile(1234, "some_file") // *os.File | file to upload
additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional) additionalMetadata := "additionalMetadata_example" // string | Additional data to pass to server (optional)
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()

View File

@ -161,7 +161,7 @@ import (
) )
func main() { func main() {
orderId := 987 // int64 | ID of pet that needs to be fetched orderId := int64(789) // int64 | ID of pet that needs to be fetched
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)

View File

@ -98,7 +98,7 @@ import (
) )
func main() { func main() {
user := []User{*openapiclient.NewUser()} // []User | List of user object user := []openapiclient.User{*openapiclient.NewUser()} // []User | List of user object
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -160,7 +160,7 @@ import (
) )
func main() { func main() {
user := []User{} // []User | List of user object user := []openapiclient.User{*openapiclient.NewUser()} // []User | List of user object
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)
@ -484,7 +484,7 @@ import (
func main() { func main() {
username := "username_example" // string | name that need to be deleted username := "username_example" // string | name that need to be deleted
user := // User | Updated user object user := *openapiclient.NewUser() // User | Updated user object
configuration := openapiclient.NewConfiguration() configuration := openapiclient.NewConfiguration()
api_client := openapiclient.NewAPIClient(configuration) api_client := openapiclient.NewAPIClient(configuration)