Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/utils/ensure-up-to-date
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ declare -a scripts=(
"./bin/csharp-netcore-petstore-all.sh"
"./bin/elixir-petstore.sh"
"./bin/openapi3/go-petstore.sh"
"./bin/go-experimental-petstore.sh"
"./bin/go-petstore.sh"
"./bin/go-petstore-withxml.sh"
"./bin/go-gin-petstore-server.sh"
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/go-experimental/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestAccessToken(t *testing.T) {
}

func TestAPIKeyNoPrefix(t *testing.T) {
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{Key: "TEST123"})
auth := context.WithValue(context.Background(), sw.ContextAPIKeys, map[string]sw.APIKey{"api_key": sw.APIKey{Key: "TEST123"}})

newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: sw.PtrString("gopher"),
PhotoUrls: &[]string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestAPIKeyNoPrefix(t *testing.T) {
}

func TestAPIKeyWithPrefix(t *testing.T) {
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{Key: "TEST123", Prefix: "Bearer"})
auth := context.WithValue(context.Background(), sw.ContextAPIKeys, map[string]sw.APIKey{"api_key": sw.APIKey{Key: "TEST123", Prefix: "Bearer"}})

newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: sw.PtrString("gopher"),
PhotoUrls: &[]string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.2-SNAPSHOT
4.1.3-SNAPSHOT
34 changes: 11 additions & 23 deletions samples/client/petstore/go-experimental/go-petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go get github.com/antihax/optional
Put the package under your project folder and add the following in import:

```golang
import "./petstore"
import sw "./petstore"
```

## Documentation for API Endpoints
Expand Down Expand Up @@ -125,37 +125,25 @@ Class | Method | HTTP request | Description



## api_key
### api_key

- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header

Example

```golang
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
Key: "APIKEY",
Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)
```
Note, each API key must be added to a map of `map[string]APIKey` where the key is: api_key and passed in as the auth context for each request.


## api_key_query
### api_key_query

- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string

Example

```golang
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
Key: "APIKEY",
Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)
```
Note, each API key must be added to a map of `map[string]APIKey` where the key is: api_key_query and passed in as the auth context for each request.


## http_basic_test
### http_basic_test

- **Type**: HTTP basic authentication

Expand All @@ -170,7 +158,7 @@ r, err := client.Service.Operation(auth, args)
```


## petstore_auth
### petstore_auth


- **Type**: OAuth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,10 @@ components:
number_item:
example: 1.234
type: number
float_item:
example: 1.234
format: float
type: number
integer_item:
example: -2
type: integer
Expand All @@ -1887,6 +1891,7 @@ components:
required:
- array_item
- bool_item
- float_item
- integer_item
- number_item
- string_item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,7 @@ func (a *FakeApiService) TestEndpointParameters(ctx _context.Context, number flo
localVarFormParams.Add("date", parameterToString(localVarOptionals.Date.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.DateTime.IsSet() {
paramJson, err := parameterToJson(localVarOptionals.DateTime.Value())
if err != nil {
return nil, err
}
localVarFormParams.Add("dateTime", paramJson)
localVarFormParams.Add("dateTime", parameterToString(localVarOptionals.DateTime.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.Password.IsSet() {
localVarFormParams.Add("password", parameterToString(localVarOptionals.Password.Value(), ""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx _context.Context, bod
localVarPostBody = &body
if ctx != nil {
// API Key Authentication
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
var key string
if auth.Prefix != "" {
key = auth.Prefix + " " + auth.Key
} else {
key = auth.Key
if auth, ok := ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
if auth, ok := auth["api_key_query"]; ok {
var key string
if auth.Prefix != "" {
key = auth.Prefix + " " + auth.Key
} else {
key = auth.Key
}
localVarQueryParams.Add("api_key_query", key)
}
localVarQueryParams.Add("api_key_query", key)
}
}
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
Expand Down
16 changes: 9 additions & 7 deletions samples/client/petstore/go-experimental/go-petstore/api_pet.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,16 @@ func (a *PetApiService) GetPetById(ctx _context.Context, petId int64) (Pet, *_ne
}
if ctx != nil {
// API Key Authentication
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
var key string
if auth.Prefix != "" {
key = auth.Prefix + " " + auth.Key
} else {
key = auth.Key
if auth, ok := ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
if auth, ok := auth["api_key"]; ok {
var key string
if auth.Prefix != "" {
key = auth.Prefix + " " + auth.Key
} else {
key = auth.Key
}
localVarHeaderParams["api_key"] = key
}
localVarHeaderParams["api_key"] = key
}
}
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
Expand Down
16 changes: 9 additions & 7 deletions samples/client/petstore/go-experimental/go-petstore/api_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,16 @@ func (a *StoreApiService) GetInventory(ctx _context.Context) (map[string]int32,
}
if ctx != nil {
// API Key Authentication
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
var key string
if auth.Prefix != "" {
key = auth.Prefix + " " + auth.Key
} else {
key = auth.Key
if auth, ok := ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
if auth, ok := auth["api_key"]; ok {
var key string
if auth.Prefix != "" {
key = auth.Prefix + " " + auth.Key
} else {
key = auth.Key
}
localVarHeaderParams["api_key"] = key
}
localVarHeaderParams["api_key"] = key
}
}
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var (
// ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAccessToken = contextKey("accesstoken")

// ContextAPIKey takes an APIKey as authentication for the request
ContextAPIKey = contextKey("apikey")
// ContextAPIKeys takes a string apikey as authentication for the request
ContextAPIKeys = contextKey("apiKeys")
)

// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**StringItem** | Pointer to **string** | |
**NumberItem** | Pointer to **float32** | |
**FloatItem** | Pointer to **float32** | |
**IntegerItem** | Pointer to **int32** | |
**BoolItem** | Pointer to **bool** | |
**ArrayItem** | Pointer to **[]int32** | |
Expand Down Expand Up @@ -62,6 +63,31 @@ HasNumberItem returns a boolean if a field has been set.

SetNumberItem gets a reference to the given float32 and assigns it to the NumberItem field.

### GetFloatItem

`func (o *TypeHolderExample) GetFloatItem() float32`

GetFloatItem returns the FloatItem field if non-nil, zero value otherwise.

### GetFloatItemOk

`func (o *TypeHolderExample) GetFloatItemOk() (float32, bool)`

GetFloatItemOk returns a tuple with the FloatItem field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### HasFloatItem

`func (o *TypeHolderExample) HasFloatItem() bool`

HasFloatItem returns a boolean if a field has been set.

### SetFloatItem

`func (o *TypeHolderExample) SetFloatItem(v float32)`

SetFloatItem gets a reference to the given float32 and assigns it to the FloatItem field.

### GetIntegerItem

`func (o *TypeHolderExample) GetIntegerItem() int32`
Expand Down
16 changes: 11 additions & 5 deletions samples/client/petstore/go-experimental/go-petstore/git_push.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"

git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4

if [ "$git_host" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi

if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
Expand All @@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .

# Commits the tracked changes and prepares them to be pushed to a remote repository.
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"

# Sets the new remote
Expand All @@ -37,16 +43,16 @@ if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi

fi

git pull origin master

# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type TypeHolderExample struct {

NumberItem *float32 `json:"number_item,omitempty"`

FloatItem *float32 `json:"float_item,omitempty"`

IntegerItem *int32 `json:"integer_item,omitempty"`

BoolItem *bool `json:"bool_item,omitempty"`
Expand Down Expand Up @@ -92,6 +94,39 @@ func (o *TypeHolderExample) SetNumberItem(v float32) {
o.NumberItem = &v
}

// GetFloatItem returns the FloatItem field if non-nil, zero value otherwise.
func (o *TypeHolderExample) GetFloatItem() float32 {
if o == nil || o.FloatItem == nil {
var ret float32
return ret
}
return *o.FloatItem
}

// GetFloatItemOk returns a tuple with the FloatItem field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (o *TypeHolderExample) GetFloatItemOk() (float32, bool) {
if o == nil || o.FloatItem == nil {
var ret float32
return ret, false
}
return *o.FloatItem, true
}

// HasFloatItem returns a boolean if a field has been set.
func (o *TypeHolderExample) HasFloatItem() bool {
if o != nil && o.FloatItem != nil {
return true
}

return false
}

// SetFloatItem gets a reference to the given float32 and assigns it to the FloatItem field.
func (o *TypeHolderExample) SetFloatItem(v float32) {
o.FloatItem = &v
}

// GetIntegerItem returns the IntegerItem field if non-nil, zero value otherwise.
func (o *TypeHolderExample) GetIntegerItem() int32 {
if o == nil || o.IntegerItem == nil {
Expand Down Expand Up @@ -207,6 +242,12 @@ func (o TypeHolderExample) MarshalJSON() ([]byte, error) {
if o.NumberItem != nil {
toSerialize["number_item"] = o.NumberItem
}
if o.FloatItem == nil {
return nil, errors.New("FloatItem is required and not nullable, but was not set on TypeHolderExample")
}
if o.FloatItem != nil {
toSerialize["float_item"] = o.FloatItem
}
if o.IntegerItem == nil {
return nil, errors.New("IntegerItem is required and not nullable, but was not set on TypeHolderExample")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0-SNAPSHOT
4.1.3-SNAPSHOT
2 changes: 1 addition & 1 deletion samples/server/petstore/go-api-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.10 AS build
WORKDIR /go/src
COPY ./
COPY go ./go
COPY main.go .

ENV CGO_ENABLED=0
Expand Down
Loading