forked from loafle/openapi-generator-original
* Fixed issue #4665 [go] required object parameters are marked omitempty. * Run ./bin/go-petstore.sh as suggested by @wing328. Please note, that there are quite few changes, that doesn’t come from the diff I’ve applied. Seems the script wasn’t run on the previous commit.
This commit is contained in:
committed by
wing328
parent
f62a7e2144
commit
96ed41a29c
@@ -9,7 +9,7 @@ import ({{/imports}}{{#imports}}
|
||||
type {{classname}} struct {
|
||||
{{#vars}}{{#description}}
|
||||
// {{{description}}}{{/description}}
|
||||
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
|
||||
{{name}} {{{datatype}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"`
|
||||
{{/vars}}
|
||||
}
|
||||
{{/model}}{{/models}}
|
||||
@@ -7,7 +7,7 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version: 1.0.0
|
||||
- Build package: class io.swagger.codegen.languages.GoClientCodegen
|
||||
- Build package: io.swagger.codegen.languages.GoClientCodegen
|
||||
|
||||
## Installation
|
||||
Put the package under your project folder and add the following in import:
|
||||
@@ -54,6 +54,7 @@ Class | Method | HTTP request | Description
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [Capitalization](docs/Capitalization.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [ClassModel](docs/ClassModel.md)
|
||||
|
||||
@@ -12,7 +12,7 @@ package petstore
|
||||
|
||||
type Animal struct {
|
||||
|
||||
ClassName string `json:"className,omitempty"`
|
||||
ClassName string `json:"className"`
|
||||
|
||||
Color string `json:"color,omitempty"`
|
||||
}
|
||||
|
||||
27
samples/client/petstore/go/go-petstore/capitalization.go
Normal file
27
samples/client/petstore/go/go-petstore/capitalization.go
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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: \" \\
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type Capitalization struct {
|
||||
|
||||
SmallCamel string `json:"smallCamel,omitempty"`
|
||||
|
||||
CapitalCamel string `json:"CapitalCamel,omitempty"`
|
||||
|
||||
SmallSnake string `json:"small_Snake,omitempty"`
|
||||
|
||||
CapitalSnake string `json:"Capital_Snake,omitempty"`
|
||||
|
||||
SCAETHFlowPoints string `json:"SCA_ETH_Flow_Points,omitempty"`
|
||||
|
||||
// Name of the pet
|
||||
ATT_NAME string `json:"ATT_NAME,omitempty"`
|
||||
}
|
||||
@@ -12,7 +12,7 @@ package petstore
|
||||
|
||||
type Cat struct {
|
||||
|
||||
ClassName string `json:"className,omitempty"`
|
||||
ClassName string `json:"className"`
|
||||
|
||||
Color string `json:"color,omitempty"`
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
|
||||
|
||||
type Configuration struct {
|
||||
UserName string `json:"userName,omitempty"`
|
||||
Username string `json:"userName,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
|
||||
APIKey map[string]string `json:"APIKey,omitempty"`
|
||||
@@ -51,7 +51,7 @@ func NewConfiguration() *Configuration {
|
||||
}
|
||||
|
||||
func (c *Configuration) GetBasicAuthEncodedString() string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
|
||||
return base64.StdEncoding.EncodeToString([]byte(c.Username + ":" + c.Password))
|
||||
}
|
||||
|
||||
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# Capitalization
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**SmallCamel** | **string** | | [optional] [default to null]
|
||||
**CapitalCamel** | **string** | | [optional] [default to null]
|
||||
**SmallSnake** | **string** | | [optional] [default to null]
|
||||
**CapitalSnake** | **string** | | [optional] [default to null]
|
||||
**SCAETHFlowPoints** | **string** | | [optional] [default to null]
|
||||
**ATT_NAME** | **string** | Name of the pet | [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,6 +1,6 @@
|
||||
# \FakeApi
|
||||
|
||||
All URIs are relative to **
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
@@ -14,6 +14,8 @@ Method | HTTP request | Description
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -83,6 +85,8 @@ void (empty response body)
|
||||
|
||||
To test enum parameters
|
||||
|
||||
To test enum parameters
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -94,7 +98,7 @@ Name | Type | Description | Notes
|
||||
**enumHeaderString** | **string**| Header parameter enum test (string) | [optional] [default to -efg]
|
||||
**enumQueryStringArray** | [**[]string**](string.md)| Query parameter enum test (string array) | [optional]
|
||||
**enumQueryString** | **string**| Query parameter enum test (string) | [optional] [default to -efg]
|
||||
**enumQueryInteger** | **float32**| Query parameter enum test (double) | [optional]
|
||||
**enumQueryInteger** | **int32**| Query parameter enum test (double) | [optional]
|
||||
**enumQueryDouble** | **float64**| Query parameter enum test (double) | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# \PetApi
|
||||
|
||||
All URIs are relative to **
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# \StoreApi
|
||||
|
||||
All URIs are relative to **
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# \UserApi
|
||||
|
||||
All URIs are relative to **
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
|
||||
@@ -12,7 +12,7 @@ package petstore
|
||||
|
||||
type Dog struct {
|
||||
|
||||
ClassName string `json:"className,omitempty"`
|
||||
ClassName string `json:"className"`
|
||||
|
||||
Color string `json:"color,omitempty"`
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ func NewFakeApiWithBasePath(basePath string) *FakeApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* To test \"client\" model
|
||||
* To test \"client\" model
|
||||
*
|
||||
* @param body client model
|
||||
@@ -132,7 +133,7 @@ func (a FakeApi) TestEndpointParameters(number float32, double float64, patternW
|
||||
var localVarFileBytes []byte
|
||||
// authentication '(http_basic_test)' required
|
||||
// http basic authentication required
|
||||
if a.Configuration.UserName != "" || a.Configuration.Password != ""{
|
||||
if a.Configuration.Username != "" || a.Configuration.Password != ""{
|
||||
localVarHeaderParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString()
|
||||
}
|
||||
// add default headers if any
|
||||
@@ -190,6 +191,7 @@ func (a FakeApi) TestEndpointParameters(number float32, double float64, patternW
|
||||
}
|
||||
|
||||
/**
|
||||
* To test enum parameters
|
||||
* To test enum parameters
|
||||
*
|
||||
* @param enumFormStringArray Form parameter enum test (string array)
|
||||
@@ -202,7 +204,7 @@ func (a FakeApi) TestEndpointParameters(number float32, double float64, patternW
|
||||
* @param enumQueryDouble Query parameter enum test (double)
|
||||
* @return void
|
||||
*/
|
||||
func (a FakeApi) TestEnumParameters(enumFormStringArray []string, enumFormString string, enumHeaderStringArray []string, enumHeaderString string, enumQueryStringArray []string, enumQueryString string, enumQueryInteger float32, enumQueryDouble float64) (*APIResponse, error) {
|
||||
func (a FakeApi) TestEnumParameters(enumFormStringArray []string, enumFormString string, enumHeaderStringArray []string, enumHeaderString string, enumQueryStringArray []string, enumQueryString string, enumQueryInteger int32, enumQueryDouble float64) (*APIResponse, error) {
|
||||
|
||||
var localVarHttpMethod = strings.ToUpper("Get")
|
||||
// create path and map variables
|
||||
|
||||
@@ -22,7 +22,7 @@ type FormatTest struct {
|
||||
|
||||
Int64_ int64 `json:"int64,omitempty"`
|
||||
|
||||
Number float32 `json:"number,omitempty"`
|
||||
Number float32 `json:"number"`
|
||||
|
||||
Float float32 `json:"float,omitempty"`
|
||||
|
||||
@@ -30,15 +30,15 @@ type FormatTest struct {
|
||||
|
||||
String_ string `json:"string,omitempty"`
|
||||
|
||||
Byte_ string `json:"byte,omitempty"`
|
||||
Byte_ string `json:"byte"`
|
||||
|
||||
Binary string `json:"binary,omitempty"`
|
||||
|
||||
Date time.Time `json:"date,omitempty"`
|
||||
Date time.Time `json:"date"`
|
||||
|
||||
DateTime time.Time `json:"dateTime,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
|
||||
Password string `json:"password,omitempty"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ package petstore
|
||||
// Model for testing model name same as property name
|
||||
type Name struct {
|
||||
|
||||
Name int32 `json:"name,omitempty"`
|
||||
Name int32 `json:"name"`
|
||||
|
||||
SnakeCase int32 `json:"snake_case,omitempty"`
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ type Pet struct {
|
||||
|
||||
Category Category `json:"category,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
Name string `json:"name"`
|
||||
|
||||
PhotoUrls []string `json:"photoUrls,omitempty"`
|
||||
PhotoUrls []string `json:"photoUrls"`
|
||||
|
||||
Tags []Tag `json:"tags,omitempty"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user