From 63a311a2e676a1c86a8899497b082121d94d6b26 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 1 Jun 2023 09:09:00 +0800 Subject: [PATCH] update go samples --- .../client/petstore/go/go-petstore/README.md | 26 +++++++++++++++++++ .../x-auth-id-alias/go-experimental/README.md | 26 +++++++++++++++++++ .../client/petstore/go/go-petstore/README.md | 26 +++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index 49ff92415f1..1274e8dbf80 100644 --- a/samples/client/petstore/go/go-petstore/README.md +++ b/samples/client/petstore/go/go-petstore/README.md @@ -210,6 +210,19 @@ 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. +Example + +```golang +auth := context.WithValue( + context.Background(), + sw.ContextAPIKeys, + map[string]sw.APIKey{ + "api_key": {Key: "API_KEY_STRING"}, + }, + ) +r, err := client.Service.Operation(auth, args) +``` + ### api_key_query - **Type**: API key @@ -218,6 +231,19 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i 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. +Example + +```golang +auth := context.WithValue( + context.Background(), + sw.ContextAPIKeys, + map[string]sw.APIKey{ + "api_key_query": {Key: "API_KEY_STRING"}, + }, + ) +r, err := client.Service.Operation(auth, args) +``` + ### http_basic_test - **Type**: HTTP basic authentication diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/README.md b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/README.md index c8d9423123e..e92494904b5 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/README.md +++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/README.md @@ -99,6 +99,19 @@ Authentication schemes defined for the API: Note, each API key must be added to a map of `map[string]APIKey` where the key is: X-Api-Key and passed in as the auth context for each request. +Example + +```golang +auth := context.WithValue( + context.Background(), + sw.ContextAPIKeys, + map[string]sw.APIKey{ + "X-Api-Key": {Key: "API_KEY_STRING"}, + }, + ) +r, err := client.Service.Operation(auth, args) +``` + ### api_key_query - **Type**: API key @@ -107,6 +120,19 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i 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. +Example + +```golang +auth := context.WithValue( + context.Background(), + sw.ContextAPIKeys, + map[string]sw.APIKey{ + "api_key": {Key: "API_KEY_STRING"}, + }, + ) +r, err := client.Service.Operation(auth, args) +``` + ## Documentation for Utility Methods diff --git a/samples/openapi3/client/petstore/go/go-petstore/README.md b/samples/openapi3/client/petstore/go/go-petstore/README.md index 42901de5338..52e28ed4862 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/README.md +++ b/samples/openapi3/client/petstore/go/go-petstore/README.md @@ -230,6 +230,19 @@ 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. +Example + +```golang +auth := context.WithValue( + context.Background(), + sw.ContextAPIKeys, + map[string]sw.APIKey{ + "api_key": {Key: "API_KEY_STRING"}, + }, + ) +r, err := client.Service.Operation(auth, args) +``` + ### api_key_query - **Type**: API key @@ -238,6 +251,19 @@ Note, each API key must be added to a map of `map[string]APIKey` where the key i 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. +Example + +```golang +auth := context.WithValue( + context.Background(), + sw.ContextAPIKeys, + map[string]sw.APIKey{ + "api_key_query": {Key: "API_KEY_STRING"}, + }, + ) +r, err := client.Service.Operation(auth, args) +``` + ### http_basic_test - **Type**: HTTP basic authentication