forked from loafle/openapi-generator-original
[go] Fix multiple go compilation errors and enable go integration test in pom.xml (#5075)
* fix go compilation error for properties of type map and array * fix go compilation error for properties of type date and datetime * add missing shell script to bin/utils/ensure-up-to-date * add missing shell script to bin/utils/ensure-up-to-date * add missing shell script to bin/utils/ensure-up-to-date * fix issue with 'date' type * fix time import problem * Add missing pom.xml files for golang * Add missing unit test files for golang * Add missing unit test files for golang. Must use class name prefix for enums * Fix unit tests for go-experimental in OAS3 * Fix unit tests for go-experimental in OAS3 * Add code comments in codegen * Fix compilation errors of generated go code * Fix compilation errors of generated go code * remove antihax from go-experimental, it is no longer used * copy python testfile for ut purpose * add error checkout in unit tests * add unit tests * add code comments * move test foo.png file to correct location * run samples scripts * run samples scripts
This commit is contained in:
parent
138232d557
commit
75d5569e92
@ -34,6 +34,8 @@ rm -rf $STUB_DIR
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR -DpackageName=petstore $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR"
|
||||||
|
ags="$ags --additional-properties enumClassPrefix=true,packageName=petstore"
|
||||||
|
ags="$ags $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -34,6 +34,8 @@ rm -rf $STUB_DIR
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/go -i $SPEC -g $GENERATOR -o $STUB_DIR --additional-properties packageName=petstore $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/go -i $SPEC -g $GENERATOR -o $STUB_DIR"
|
||||||
|
ags="$ags --additional-properties enumClassPrefix=true,packageName=petstore"
|
||||||
|
ags="$ags $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -66,6 +66,7 @@ declare -a samples=(
|
|||||||
"${root}/bin/csharp-netcore-petstore-all.sh"
|
"${root}/bin/csharp-netcore-petstore-all.sh"
|
||||||
"${root}/bin/elixir-petstore.sh"
|
"${root}/bin/elixir-petstore.sh"
|
||||||
"${root}/bin/openapi3/go-petstore.sh"
|
"${root}/bin/openapi3/go-petstore.sh"
|
||||||
|
"${root}/bin/openapi3/go-experimental-petstore.sh"
|
||||||
"${root}/bin/go-experimental-petstore.sh"
|
"${root}/bin/go-experimental-petstore.sh"
|
||||||
"${root}/bin/go-petstore.sh"
|
"${root}/bin/go-petstore.sh"
|
||||||
"${root}/bin/go-petstore-withxml.sh"
|
"${root}/bin/go-petstore-withxml.sh"
|
||||||
|
@ -24,8 +24,16 @@ import java.util.*;
|
|||||||
|
|
||||||
@JsonIgnoreProperties({"parentModel", "interfaceModels"})
|
@JsonIgnoreProperties({"parentModel", "interfaceModels"})
|
||||||
public class CodegenModel implements IJsonSchemaValidationProperties {
|
public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||||
|
// The parent model name from the schemas. The parent is determined by inspecting the allOf, anyOf and
|
||||||
|
// oneOf attributes in the OAS. First codegen inspects 'allOf', then 'anyOf', then 'oneOf'.
|
||||||
|
// If there are multiple object references in the attribute ('allOf', 'anyOf', 'oneOf'), and one of the
|
||||||
|
// object is a discriminator, that object is set as the parent. If no discriminator is specified,
|
||||||
|
// codegen returns the first one in the list, i.e. there is no obvious parent in the OpenAPI specification.
|
||||||
|
// When possible, the mustache templates should use 'allParents' to handle multiple parents.
|
||||||
public String parent, parentSchema;
|
public String parent, parentSchema;
|
||||||
public List<String> interfaces;
|
public List<String> interfaces;
|
||||||
|
// The list of parent model name from the schemas. In order of preference, the parent is obtained
|
||||||
|
// from the 'allOf' attribute, then 'anyOf', and finally 'oneOf'.
|
||||||
public List<String> allParents;
|
public List<String> allParents;
|
||||||
|
|
||||||
// References to parent and interface CodegenModels. Only set when code generator supports inheritance.
|
// References to parent and interface CodegenModels. Only set when code generator supports inheritance.
|
||||||
|
@ -70,8 +70,8 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
public boolean isBinary;
|
public boolean isBinary;
|
||||||
public boolean isFile;
|
public boolean isFile;
|
||||||
public boolean isBoolean;
|
public boolean isBoolean;
|
||||||
public boolean isDate;
|
public boolean isDate; // full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21
|
||||||
public boolean isDateTime;
|
public boolean isDateTime; // the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z
|
||||||
public boolean isUuid;
|
public boolean isUuid;
|
||||||
public boolean isUri;
|
public boolean isUri;
|
||||||
public boolean isEmail;
|
public boolean isEmail;
|
||||||
|
@ -71,7 +71,6 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
objs = super.postProcessModels(objs);
|
|
||||||
|
|
||||||
List<Map<String, Object>> models = (List<Map<String, Object>>) objs.get("models");
|
List<Map<String, Object>> models = (List<Map<String, Object>>) objs.get("models");
|
||||||
for (Map<String, Object> m : models) {
|
for (Map<String, Object> m : models) {
|
||||||
@ -83,16 +82,27 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (CodegenProperty param : model.vars) {
|
for (CodegenProperty param : model.vars) {
|
||||||
if (!param.isNullable) {
|
if (!param.isNullable || param.isMapContainer || param.isListContainer) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (param.isDateTime) {
|
||||||
|
// Note this could have been done by adding the following line in processOpts(),
|
||||||
|
// however, we only want to represent the DateTime object as NullableTime if
|
||||||
|
// it's marked as nullable in the spec.
|
||||||
|
// typeMapping.put("DateTime", "NullableTime");
|
||||||
|
param.dataType = "NullableTime";
|
||||||
|
} else {
|
||||||
param.dataType = "Nullable" + Character.toUpperCase(param.dataType.charAt(0))
|
param.dataType = "Nullable" + Character.toUpperCase(param.dataType.charAt(0))
|
||||||
+ param.dataType.substring(1);
|
+ param.dataType.substring(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The superclass determines the list of required golang imports. The actual list of imports
|
||||||
|
// depends on which types are used, which is done in the code above. So super.postProcessModels
|
||||||
|
// must be invoked at the end of this method.
|
||||||
|
objs = super.postProcessModels(objs);
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -921,7 +921,8 @@ public class ModelUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the the parent model name from the schemas (allOf, anyOf, oneOf)
|
* Get the parent model name from the schemas (allOf, anyOf, oneOf).
|
||||||
|
* If there are multiple parents, return the first one.
|
||||||
*
|
*
|
||||||
* @param composedSchema schema (alias or direct reference)
|
* @param composedSchema schema (alias or direct reference)
|
||||||
* @param allSchemas all schemas
|
* @param allSchemas all schemas
|
||||||
@ -965,6 +966,14 @@ public class ModelUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of parent model names from the schemas (allOf, anyOf, oneOf).
|
||||||
|
*
|
||||||
|
* @param composedSchema schema (alias or direct reference)
|
||||||
|
* @param allSchemas all schemas
|
||||||
|
* @param includeAncestors if true, include the indirect ancestors in the return value. If false, return the direct parents.
|
||||||
|
* @return the name of the parent model
|
||||||
|
*/
|
||||||
public static List<String> getAllParentsName(ComposedSchema composedSchema, Map<String, Schema> allSchemas, boolean includeAncestors) {
|
public static List<String> getAllParentsName(ComposedSchema composedSchema, Map<String, Schema> allSchemas, boolean includeAncestors) {
|
||||||
List<Schema> interfaces = getInterfaces(composedSchema);
|
List<Schema> interfaces = getInterfaces(composedSchema);
|
||||||
List<String> names = new ArrayList<String>();
|
List<String> names = new ArrayList<String>();
|
||||||
|
@ -25,7 +25,6 @@ Install the following dependencies:
|
|||||||
go get github.com/stretchr/testify/assert
|
go get github.com/stretchr/testify/assert
|
||||||
go get golang.org/x/oauth2
|
go get golang.org/x/oauth2
|
||||||
go get golang.org/x/net/context
|
go get golang.org/x/net/context
|
||||||
go get github.com/antihax/optional
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Put the package under your project folder and add the following in import:
|
Put the package under your project folder and add the following in import:
|
||||||
|
@ -3,6 +3,5 @@ module {{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/antihax/optional v1.0.0
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||||
)
|
)
|
||||||
|
@ -135,6 +135,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams
|
|||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
{{#required}}
|
{{#required}}
|
||||||
{{#isCollectionFormatMulti}}
|
{{#isCollectionFormatMulti}}
|
||||||
|
{
|
||||||
t:={{paramName}}
|
t:={{paramName}}
|
||||||
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
||||||
s := reflect.ValueOf(t)
|
s := reflect.ValueOf(t)
|
||||||
@ -144,6 +145,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams
|
|||||||
} else {
|
} else {
|
||||||
localVarQueryParams.Add("{{baseName}}", parameterToString(t, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"))
|
localVarQueryParams.Add("{{baseName}}", parameterToString(t, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
{{/isCollectionFormatMulti}}
|
{{/isCollectionFormatMulti}}
|
||||||
{{^isCollectionFormatMulti}}
|
{{^isCollectionFormatMulti}}
|
||||||
localVarQueryParams.Add("{{baseName}}", parameterToString({{paramName}}, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"))
|
localVarQueryParams.Add("{{baseName}}", parameterToString({{paramName}}, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"))
|
||||||
|
2
pom.xml
2
pom.xml
@ -1087,6 +1087,8 @@
|
|||||||
<!-- test non-java projects -->
|
<!-- test non-java projects -->
|
||||||
<module>samples/client/petstore/go</module>
|
<module>samples/client/petstore/go</module>
|
||||||
<module>samples/client/petstore/go-experimental</module>
|
<module>samples/client/petstore/go-experimental</module>
|
||||||
|
<module>samples/openapi3/client/petstore/go-experimental</module>
|
||||||
|
<module>samples/openapi3/client/petstore/go</module>
|
||||||
<!-- test java-related projects -->
|
<!-- test java-related projects -->
|
||||||
<!--<module>samples/client/petstore/scala-akka</module>-->
|
<!--<module>samples/client/petstore/scala-akka</module>-->
|
||||||
<module>samples/client/petstore/scala-httpclient</module>
|
<module>samples/client/petstore/scala-httpclient</module>
|
||||||
|
@ -17,7 +17,6 @@ Install the following dependencies:
|
|||||||
go get github.com/stretchr/testify/assert
|
go get github.com/stretchr/testify/assert
|
||||||
go get golang.org/x/oauth2
|
go get golang.org/x/oauth2
|
||||||
go get golang.org/x/net/context
|
go get golang.org/x/net/context
|
||||||
go get github.com/antihax/optional
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Put the package under your project folder and add the following in import:
|
Put the package under your project folder and add the following in import:
|
||||||
|
@ -3,6 +3,5 @@ module github.com/GIT_USER_ID/GIT_REPO_ID
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/antihax/optional v1.0.0
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||||
)
|
)
|
||||||
|
@ -139,7 +139,10 @@ func TestFindPetsByStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUploadFile(t *testing.T) {
|
func TestUploadFile(t *testing.T) {
|
||||||
file, _ := os.Open("../python/testfiles/foo.png")
|
file, err1 := os.Open("testfiles/foo.png")
|
||||||
|
if err1 != nil {
|
||||||
|
t.Fatalf("Error opening file: %v", err1)
|
||||||
|
}
|
||||||
|
|
||||||
_, r, err := client.PetApi.UploadFile(context.Background(), 12830).AdditionalMetadata("golang").File(file).Execute()
|
_, r, err := client.PetApi.UploadFile(context.Background(), 12830).AdditionalMetadata("golang").File(file).Execute()
|
||||||
|
|
||||||
@ -154,7 +157,10 @@ func TestUploadFile(t *testing.T) {
|
|||||||
|
|
||||||
func TestUploadFileRequired(t *testing.T) {
|
func TestUploadFileRequired(t *testing.T) {
|
||||||
return // remove when server supports this endpoint
|
return // remove when server supports this endpoint
|
||||||
file, _ := os.Open("../python/testfiles/foo.png")
|
file, err1 := os.Open("testfiles/foo.png")
|
||||||
|
if err1 != nil {
|
||||||
|
t.Fatalf("Error opening file: %v", err1)
|
||||||
|
}
|
||||||
|
|
||||||
_, r, err := client.PetApi.UploadFileWithRequiredFile(context.Background(), 12830).RequiredFile(file).AdditionalMetadata("golang").Execute()
|
_, r, err := client.PetApi.UploadFileWithRequiredFile(context.Background(), 12830).RequiredFile(file).AdditionalMetadata("golang").Execute()
|
||||||
|
|
||||||
|
@ -68,20 +68,6 @@
|
|||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
|
||||||
<id>go-get-optional</id>
|
|
||||||
<phase>pre-integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>exec</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<executable>go</executable>
|
|
||||||
<arguments>
|
|
||||||
<argument>get</argument>
|
|
||||||
<argument>github.com/antihax/optional</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
<execution>
|
||||||
<id>go-test</id>
|
<id>go-test</id>
|
||||||
<phase>integration-test</phase>
|
<phase>integration-test</phase>
|
||||||
|
BIN
samples/client/petstore/go-experimental/testfiles/foo.png
Normal file
BIN
samples/client/petstore/go-experimental/testfiles/foo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
@ -1217,6 +1217,7 @@ func (a *FakeApiService) TestQueryParameterCollectionFormat(ctx _context.Context
|
|||||||
localVarQueryParams.Add("ioutil", parameterToString(ioutil, "csv"))
|
localVarQueryParams.Add("ioutil", parameterToString(ioutil, "csv"))
|
||||||
localVarQueryParams.Add("http", parameterToString(http, "space"))
|
localVarQueryParams.Add("http", parameterToString(http, "space"))
|
||||||
localVarQueryParams.Add("url", parameterToString(url, "csv"))
|
localVarQueryParams.Add("url", parameterToString(url, "csv"))
|
||||||
|
{
|
||||||
t:=context
|
t:=context
|
||||||
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
||||||
s := reflect.ValueOf(t)
|
s := reflect.ValueOf(t)
|
||||||
@ -1226,6 +1227,7 @@ func (a *FakeApiService) TestQueryParameterCollectionFormat(ctx _context.Context
|
|||||||
} else {
|
} else {
|
||||||
localVarQueryParams.Add("context", parameterToString(t, "multi"))
|
localVarQueryParams.Add("context", parameterToString(t, "multi"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHTTPContentTypes := []string{}
|
localVarHTTPContentTypes := []string{}
|
||||||
|
|
||||||
|
@ -1216,6 +1216,7 @@ func (a *FakeApiService) TestQueryParameterCollectionFormat(ctx _context.Context
|
|||||||
localVarQueryParams.Add("ioutil", parameterToString(ioutil, "csv"))
|
localVarQueryParams.Add("ioutil", parameterToString(ioutil, "csv"))
|
||||||
localVarQueryParams.Add("http", parameterToString(http, "space"))
|
localVarQueryParams.Add("http", parameterToString(http, "space"))
|
||||||
localVarQueryParams.Add("url", parameterToString(url, "csv"))
|
localVarQueryParams.Add("url", parameterToString(url, "csv"))
|
||||||
|
{
|
||||||
t:=context
|
t:=context
|
||||||
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
||||||
s := reflect.ValueOf(t)
|
s := reflect.ValueOf(t)
|
||||||
@ -1225,6 +1226,7 @@ func (a *FakeApiService) TestQueryParameterCollectionFormat(ctx _context.Context
|
|||||||
} else {
|
} else {
|
||||||
localVarQueryParams.Add("context", parameterToString(t, "multi"))
|
localVarQueryParams.Add("context", parameterToString(t, "multi"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHTTPContentTypes := []string{}
|
localVarHTTPContentTypes := []string{}
|
||||||
|
|
||||||
|
@ -142,7 +142,10 @@ func TestFindPetsByStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUploadFile(t *testing.T) {
|
func TestUploadFile(t *testing.T) {
|
||||||
file, _ := os.Open("../python/testfiles/foo.png")
|
file, err1 := os.Open("testfiles/foo.png")
|
||||||
|
if err1 != nil {
|
||||||
|
t.Fatalf("Error opening file: %v", err1)
|
||||||
|
}
|
||||||
|
|
||||||
_, r, err := client.PetApi.UploadFile(context.Background(), 12830, &sw.UploadFileOpts{
|
_, r, err := client.PetApi.UploadFile(context.Background(), 12830, &sw.UploadFileOpts{
|
||||||
AdditionalMetadata: optional.NewString("golang"),
|
AdditionalMetadata: optional.NewString("golang"),
|
||||||
@ -160,7 +163,10 @@ func TestUploadFile(t *testing.T) {
|
|||||||
|
|
||||||
func TestUploadFileRequired(t *testing.T) {
|
func TestUploadFileRequired(t *testing.T) {
|
||||||
return // remove when server supports this endpoint
|
return // remove when server supports this endpoint
|
||||||
file, _ := os.Open("../python/testfiles/foo.png")
|
file, err1 := os.Open("testfiles/foo.png")
|
||||||
|
if err1 != nil {
|
||||||
|
t.Fatalf("Error opening file: %v", err1)
|
||||||
|
}
|
||||||
|
|
||||||
_, r, err := client.PetApi.UploadFileWithRequiredFile(context.Background(), 12830,
|
_, r, err := client.PetApi.UploadFileWithRequiredFile(context.Background(), 12830,
|
||||||
file,
|
file,
|
||||||
|
BIN
samples/client/petstore/go/testfiles/foo.png
Normal file
BIN
samples/client/petstore/go/testfiles/foo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
259
samples/openapi3/client/petstore/go-experimental/auth_test.go
Normal file
259
samples/openapi3/client/petstore/go-experimental/auth_test.go
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/oauth2"
|
||||||
|
|
||||||
|
sw "./go-petstore"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOAuth2(t *testing.T) {
|
||||||
|
// Setup some fake oauth2 configuration
|
||||||
|
cfg := &oauth2.Config{
|
||||||
|
ClientID: "1234567",
|
||||||
|
ClientSecret: "SuperSecret",
|
||||||
|
Endpoint: oauth2.Endpoint{
|
||||||
|
AuthURL: "https://devnull",
|
||||||
|
TokenURL: "https://devnull",
|
||||||
|
},
|
||||||
|
RedirectURL: "https://devnull",
|
||||||
|
}
|
||||||
|
|
||||||
|
// and a fake token
|
||||||
|
tok := oauth2.Token{
|
||||||
|
AccessToken: "FAKE",
|
||||||
|
RefreshToken: "So Fake",
|
||||||
|
Expiry: time.Now().Add(time.Hour * 100000),
|
||||||
|
TokenType: "Bearer",
|
||||||
|
}
|
||||||
|
|
||||||
|
// then a fake tokenSource
|
||||||
|
tokenSource := cfg.TokenSource(createContext(nil), &tok)
|
||||||
|
auth := context.WithValue(context.Background(), sw.ContextOAuth2, tokenSource)
|
||||||
|
|
||||||
|
newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
|
||||||
|
Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(context.Background()).Pet(newPet).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
|
||||||
|
if !strings.Contains((string)(reqb), "Authorization: Bearer FAKE") {
|
||||||
|
t.Errorf("OAuth2 Authentication is missing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBasicAuth(t *testing.T) {
|
||||||
|
|
||||||
|
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
|
||||||
|
UserName: "fakeUser",
|
||||||
|
Password: "f4k3p455",
|
||||||
|
})
|
||||||
|
|
||||||
|
newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
|
||||||
|
Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(auth).Pet(newPet).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Authorization: Basic ZmFrZVVzZXI6ZjRrM3A0NTU") {
|
||||||
|
t.Errorf("Basic Authentication is missing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAccessToken(t *testing.T) {
|
||||||
|
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "TESTFAKEACCESSTOKENISFAKE")
|
||||||
|
|
||||||
|
newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
|
||||||
|
Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(nil).Pet(newPet).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Authorization: Bearer TESTFAKEACCESSTOKENISFAKE") {
|
||||||
|
t.Errorf("AccessToken Authentication is missing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAPIKeyNoPrefix(t *testing.T) {
|
||||||
|
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: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
|
||||||
|
Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(context.Background()).Pet(newPet).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, r, err = client.PetApi.GetPetById(auth, 12992).Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Api_key: TEST123") {
|
||||||
|
t.Errorf("APIKey Authentication is missing")
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992).Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAPIKeyWithPrefix(t *testing.T) {
|
||||||
|
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: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
|
||||||
|
Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(nil).Pet(newPet).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, r, err = client.PetApi.GetPetById(auth, 12992).Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Api_key: Bearer TEST123") {
|
||||||
|
t.Errorf("APIKey Authentication is missing")
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992).Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDefaultHeader(t *testing.T) {
|
||||||
|
newPet := (sw.Pet{Id: sw.PtrInt64(12992), Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
|
||||||
|
Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(context.Background()).Pet(newPet).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(context.Background(), 12992).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Testheader: testvalue") {
|
||||||
|
t.Errorf("Default Header is missing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHostOverride(t *testing.T) {
|
||||||
|
_, r, err := client.PetApi.FindPetsByStatus(context.Background()).Status(nil).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while finding pets by status: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Request.URL.Host != testHost {
|
||||||
|
t.Errorf("Request Host is %v, expected %v", r.Request.Host, testHost)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSchemeOverride(t *testing.T) {
|
||||||
|
_, r, err := client.PetApi.FindPetsByStatus(context.Background()).Status(nil).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while finding pets by status: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Request.URL.Scheme != testScheme {
|
||||||
|
t.Errorf("Request Scheme is %v, expected %v", r.Request.URL.Scheme, testScheme)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add custom clients to the context.
|
||||||
|
func createContext(httpClient *http.Client) context.Context {
|
||||||
|
parent := oauth2.NoContext
|
||||||
|
ctx := context.WithValue(parent, oauth2.HTTPClient, httpClient)
|
||||||
|
return ctx
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
sw "./go-petstore"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestPutBodyWithFileSchema ensures a model with the name 'File'
|
||||||
|
// gets converted properly to the petstore.File struct vs. *os.File
|
||||||
|
// as specified in typeMapping for 'File'.
|
||||||
|
func TestPutBodyWithFileSchema(t *testing.T) {
|
||||||
|
return // early return to test compilation
|
||||||
|
|
||||||
|
schema := sw.FileSchemaTestClass{
|
||||||
|
File: &sw.File{SourceURI: sw.PtrString("https://example.com/image.png")},
|
||||||
|
Files: &[]sw.File{{SourceURI: sw.PtrString("https://example.com/image.png")}}}
|
||||||
|
|
||||||
|
r, err := client.FakeApi.TestBodyWithFileSchema(context.Background()).FileSchemaTestClass(schema).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
# Go API client for openapi
|
# Go API client for 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: \" \\
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
@ -17,13 +17,12 @@ Install the following dependencies:
|
|||||||
go get github.com/stretchr/testify/assert
|
go get github.com/stretchr/testify/assert
|
||||||
go get golang.org/x/oauth2
|
go get golang.org/x/oauth2
|
||||||
go get golang.org/x/net/context
|
go get golang.org/x/net/context
|
||||||
go get github.com/antihax/optional
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Put the package under your project folder and add the following in import:
|
Put the package under your project folder and add the following in import:
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
import sw "./openapi"
|
import sw "./petstore"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration of Server URL
|
## Configuration of Server URL
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_context "context"
|
_context "context"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_context "context"
|
_context "context"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_context "context"
|
_context "context"
|
||||||
@ -1767,6 +1767,7 @@ func (r apiTestQueryParameterCollectionFormatRequest) Execute() (*_nethttp.Respo
|
|||||||
return nil, reportError("context is required and must be specified")
|
return nil, reportError("context is required and must be specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
t := *r.pipe
|
t := *r.pipe
|
||||||
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
||||||
s := reflect.ValueOf(t)
|
s := reflect.ValueOf(t)
|
||||||
@ -1776,9 +1777,11 @@ func (r apiTestQueryParameterCollectionFormatRequest) Execute() (*_nethttp.Respo
|
|||||||
} else {
|
} else {
|
||||||
localVarQueryParams.Add("pipe", parameterToString(t, "multi"))
|
localVarQueryParams.Add("pipe", parameterToString(t, "multi"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
localVarQueryParams.Add("ioutil", parameterToString(*r.ioutil, "csv"))
|
localVarQueryParams.Add("ioutil", parameterToString(*r.ioutil, "csv"))
|
||||||
localVarQueryParams.Add("http", parameterToString(*r.http, "space"))
|
localVarQueryParams.Add("http", parameterToString(*r.http, "space"))
|
||||||
localVarQueryParams.Add("url", parameterToString(*r.url, "csv"))
|
localVarQueryParams.Add("url", parameterToString(*r.url, "csv"))
|
||||||
|
{
|
||||||
t := *r.context
|
t := *r.context
|
||||||
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
||||||
s := reflect.ValueOf(t)
|
s := reflect.ValueOf(t)
|
||||||
@ -1788,6 +1791,7 @@ func (r apiTestQueryParameterCollectionFormatRequest) Execute() (*_nethttp.Respo
|
|||||||
} else {
|
} else {
|
||||||
localVarQueryParams.Add("context", parameterToString(t, "multi"))
|
localVarQueryParams.Add("context", parameterToString(t, "multi"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHTTPContentTypes := []string{}
|
localVarHTTPContentTypes := []string{}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_context "context"
|
_context "context"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_context "context"
|
_context "context"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_context "context"
|
_context "context"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_context "context"
|
_context "context"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -9,12 +9,12 @@ Name | Type | Description | Notes
|
|||||||
**BooleanProp** | Pointer to **NullableBool** | | [optional]
|
**BooleanProp** | Pointer to **NullableBool** | | [optional]
|
||||||
**StringProp** | Pointer to **NullableString** | | [optional]
|
**StringProp** | Pointer to **NullableString** | | [optional]
|
||||||
**DateProp** | Pointer to **NullableString** | | [optional]
|
**DateProp** | Pointer to **NullableString** | | [optional]
|
||||||
**DatetimeProp** | Pointer to [**NullableTime.Time**](time.Time.md) | | [optional]
|
**DatetimeProp** | Pointer to [**NullableTime**](time.Time.md) | | [optional]
|
||||||
**ArrayNullableProp** | Pointer to [**Nullable[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ArrayNullableProp** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
||||||
**ArrayAndItemsNullableProp** | Pointer to [**Nullable[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ArrayAndItemsNullableProp** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
||||||
**ArrayItemsNullable** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ArrayItemsNullable** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
||||||
**ObjectNullableProp** | Pointer to [**NullableMap[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ObjectNullableProp** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
||||||
**ObjectAndItemsNullableProp** | Pointer to [**NullableMap[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ObjectAndItemsNullableProp** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
||||||
**ObjectItemsNullable** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ObjectItemsNullable** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
@ -181,13 +181,13 @@ when serializing to JSON (pass true as argument to set this, false to unset)
|
|||||||
The DateProp value is set to nil even if false is passed
|
The DateProp value is set to nil even if false is passed
|
||||||
### GetDatetimeProp
|
### GetDatetimeProp
|
||||||
|
|
||||||
`func (o *NullableClass) GetDatetimeProp() NullableTime.Time`
|
`func (o *NullableClass) GetDatetimeProp() NullableTime`
|
||||||
|
|
||||||
GetDatetimeProp returns the DatetimeProp field if non-nil, zero value otherwise.
|
GetDatetimeProp returns the DatetimeProp field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
### GetDatetimePropOk
|
### GetDatetimePropOk
|
||||||
|
|
||||||
`func (o *NullableClass) GetDatetimePropOk() (NullableTime.Time, bool)`
|
`func (o *NullableClass) GetDatetimePropOk() (NullableTime, bool)`
|
||||||
|
|
||||||
GetDatetimePropOk returns a tuple with the DatetimeProp field if it's non-nil, zero value otherwise
|
GetDatetimePropOk returns a tuple with the DatetimeProp field if it's non-nil, zero value otherwise
|
||||||
and a boolean to check if the value has been set.
|
and a boolean to check if the value has been set.
|
||||||
@ -200,9 +200,9 @@ HasDatetimeProp returns a boolean if a field has been set.
|
|||||||
|
|
||||||
### SetDatetimeProp
|
### SetDatetimeProp
|
||||||
|
|
||||||
`func (o *NullableClass) SetDatetimeProp(v NullableTime.Time)`
|
`func (o *NullableClass) SetDatetimeProp(v NullableTime)`
|
||||||
|
|
||||||
SetDatetimeProp gets a reference to the given NullableTime.Time and assigns it to the DatetimeProp field.
|
SetDatetimeProp gets a reference to the given NullableTime and assigns it to the DatetimeProp field.
|
||||||
|
|
||||||
### SetDatetimePropExplicitNull
|
### SetDatetimePropExplicitNull
|
||||||
|
|
||||||
@ -213,13 +213,13 @@ when serializing to JSON (pass true as argument to set this, false to unset)
|
|||||||
The DatetimeProp value is set to nil even if false is passed
|
The DatetimeProp value is set to nil even if false is passed
|
||||||
### GetArrayNullableProp
|
### GetArrayNullableProp
|
||||||
|
|
||||||
`func (o *NullableClass) GetArrayNullableProp() Nullable[]map[string]interface{}`
|
`func (o *NullableClass) GetArrayNullableProp() []map[string]interface{}`
|
||||||
|
|
||||||
GetArrayNullableProp returns the ArrayNullableProp field if non-nil, zero value otherwise.
|
GetArrayNullableProp returns the ArrayNullableProp field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
### GetArrayNullablePropOk
|
### GetArrayNullablePropOk
|
||||||
|
|
||||||
`func (o *NullableClass) GetArrayNullablePropOk() (Nullable[]map[string]interface{}, bool)`
|
`func (o *NullableClass) GetArrayNullablePropOk() ([]map[string]interface{}, bool)`
|
||||||
|
|
||||||
GetArrayNullablePropOk returns a tuple with the ArrayNullableProp field if it's non-nil, zero value otherwise
|
GetArrayNullablePropOk returns a tuple with the ArrayNullableProp field if it's non-nil, zero value otherwise
|
||||||
and a boolean to check if the value has been set.
|
and a boolean to check if the value has been set.
|
||||||
@ -232,9 +232,9 @@ HasArrayNullableProp returns a boolean if a field has been set.
|
|||||||
|
|
||||||
### SetArrayNullableProp
|
### SetArrayNullableProp
|
||||||
|
|
||||||
`func (o *NullableClass) SetArrayNullableProp(v Nullable[]map[string]interface{})`
|
`func (o *NullableClass) SetArrayNullableProp(v []map[string]interface{})`
|
||||||
|
|
||||||
SetArrayNullableProp gets a reference to the given Nullable[]map[string]interface{} and assigns it to the ArrayNullableProp field.
|
SetArrayNullableProp gets a reference to the given []map[string]interface{} and assigns it to the ArrayNullableProp field.
|
||||||
|
|
||||||
### SetArrayNullablePropExplicitNull
|
### SetArrayNullablePropExplicitNull
|
||||||
|
|
||||||
@ -245,13 +245,13 @@ when serializing to JSON (pass true as argument to set this, false to unset)
|
|||||||
The ArrayNullableProp value is set to nil even if false is passed
|
The ArrayNullableProp value is set to nil even if false is passed
|
||||||
### GetArrayAndItemsNullableProp
|
### GetArrayAndItemsNullableProp
|
||||||
|
|
||||||
`func (o *NullableClass) GetArrayAndItemsNullableProp() Nullable[]map[string]interface{}`
|
`func (o *NullableClass) GetArrayAndItemsNullableProp() []map[string]interface{}`
|
||||||
|
|
||||||
GetArrayAndItemsNullableProp returns the ArrayAndItemsNullableProp field if non-nil, zero value otherwise.
|
GetArrayAndItemsNullableProp returns the ArrayAndItemsNullableProp field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
### GetArrayAndItemsNullablePropOk
|
### GetArrayAndItemsNullablePropOk
|
||||||
|
|
||||||
`func (o *NullableClass) GetArrayAndItemsNullablePropOk() (Nullable[]map[string]interface{}, bool)`
|
`func (o *NullableClass) GetArrayAndItemsNullablePropOk() ([]map[string]interface{}, bool)`
|
||||||
|
|
||||||
GetArrayAndItemsNullablePropOk returns a tuple with the ArrayAndItemsNullableProp field if it's non-nil, zero value otherwise
|
GetArrayAndItemsNullablePropOk returns a tuple with the ArrayAndItemsNullableProp field if it's non-nil, zero value otherwise
|
||||||
and a boolean to check if the value has been set.
|
and a boolean to check if the value has been set.
|
||||||
@ -264,9 +264,9 @@ HasArrayAndItemsNullableProp returns a boolean if a field has been set.
|
|||||||
|
|
||||||
### SetArrayAndItemsNullableProp
|
### SetArrayAndItemsNullableProp
|
||||||
|
|
||||||
`func (o *NullableClass) SetArrayAndItemsNullableProp(v Nullable[]map[string]interface{})`
|
`func (o *NullableClass) SetArrayAndItemsNullableProp(v []map[string]interface{})`
|
||||||
|
|
||||||
SetArrayAndItemsNullableProp gets a reference to the given Nullable[]map[string]interface{} and assigns it to the ArrayAndItemsNullableProp field.
|
SetArrayAndItemsNullableProp gets a reference to the given []map[string]interface{} and assigns it to the ArrayAndItemsNullableProp field.
|
||||||
|
|
||||||
### SetArrayAndItemsNullablePropExplicitNull
|
### SetArrayAndItemsNullablePropExplicitNull
|
||||||
|
|
||||||
@ -302,13 +302,13 @@ SetArrayItemsNullable gets a reference to the given []map[string]interface{} and
|
|||||||
|
|
||||||
### GetObjectNullableProp
|
### GetObjectNullableProp
|
||||||
|
|
||||||
`func (o *NullableClass) GetObjectNullableProp() NullableMap[string]map[string]interface{}`
|
`func (o *NullableClass) GetObjectNullableProp() map[string]map[string]interface{}`
|
||||||
|
|
||||||
GetObjectNullableProp returns the ObjectNullableProp field if non-nil, zero value otherwise.
|
GetObjectNullableProp returns the ObjectNullableProp field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
### GetObjectNullablePropOk
|
### GetObjectNullablePropOk
|
||||||
|
|
||||||
`func (o *NullableClass) GetObjectNullablePropOk() (NullableMap[string]map[string]interface{}, bool)`
|
`func (o *NullableClass) GetObjectNullablePropOk() (map[string]map[string]interface{}, bool)`
|
||||||
|
|
||||||
GetObjectNullablePropOk returns a tuple with the ObjectNullableProp field if it's non-nil, zero value otherwise
|
GetObjectNullablePropOk returns a tuple with the ObjectNullableProp field if it's non-nil, zero value otherwise
|
||||||
and a boolean to check if the value has been set.
|
and a boolean to check if the value has been set.
|
||||||
@ -321,9 +321,9 @@ HasObjectNullableProp returns a boolean if a field has been set.
|
|||||||
|
|
||||||
### SetObjectNullableProp
|
### SetObjectNullableProp
|
||||||
|
|
||||||
`func (o *NullableClass) SetObjectNullableProp(v NullableMap[string]map[string]interface{})`
|
`func (o *NullableClass) SetObjectNullableProp(v map[string]map[string]interface{})`
|
||||||
|
|
||||||
SetObjectNullableProp gets a reference to the given NullableMap[string]map[string]interface{} and assigns it to the ObjectNullableProp field.
|
SetObjectNullableProp gets a reference to the given map[string]map[string]interface{} and assigns it to the ObjectNullableProp field.
|
||||||
|
|
||||||
### SetObjectNullablePropExplicitNull
|
### SetObjectNullablePropExplicitNull
|
||||||
|
|
||||||
@ -334,13 +334,13 @@ when serializing to JSON (pass true as argument to set this, false to unset)
|
|||||||
The ObjectNullableProp value is set to nil even if false is passed
|
The ObjectNullableProp value is set to nil even if false is passed
|
||||||
### GetObjectAndItemsNullableProp
|
### GetObjectAndItemsNullableProp
|
||||||
|
|
||||||
`func (o *NullableClass) GetObjectAndItemsNullableProp() NullableMap[string]map[string]interface{}`
|
`func (o *NullableClass) GetObjectAndItemsNullableProp() map[string]map[string]interface{}`
|
||||||
|
|
||||||
GetObjectAndItemsNullableProp returns the ObjectAndItemsNullableProp field if non-nil, zero value otherwise.
|
GetObjectAndItemsNullableProp returns the ObjectAndItemsNullableProp field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
### GetObjectAndItemsNullablePropOk
|
### GetObjectAndItemsNullablePropOk
|
||||||
|
|
||||||
`func (o *NullableClass) GetObjectAndItemsNullablePropOk() (NullableMap[string]map[string]interface{}, bool)`
|
`func (o *NullableClass) GetObjectAndItemsNullablePropOk() (map[string]map[string]interface{}, bool)`
|
||||||
|
|
||||||
GetObjectAndItemsNullablePropOk returns a tuple with the ObjectAndItemsNullableProp field if it's non-nil, zero value otherwise
|
GetObjectAndItemsNullablePropOk returns a tuple with the ObjectAndItemsNullableProp field if it's non-nil, zero value otherwise
|
||||||
and a boolean to check if the value has been set.
|
and a boolean to check if the value has been set.
|
||||||
@ -353,9 +353,9 @@ HasObjectAndItemsNullableProp returns a boolean if a field has been set.
|
|||||||
|
|
||||||
### SetObjectAndItemsNullableProp
|
### SetObjectAndItemsNullableProp
|
||||||
|
|
||||||
`func (o *NullableClass) SetObjectAndItemsNullableProp(v NullableMap[string]map[string]interface{})`
|
`func (o *NullableClass) SetObjectAndItemsNullableProp(v map[string]map[string]interface{})`
|
||||||
|
|
||||||
SetObjectAndItemsNullableProp gets a reference to the given NullableMap[string]map[string]interface{} and assigns it to the ObjectAndItemsNullableProp field.
|
SetObjectAndItemsNullableProp gets a reference to the given map[string]map[string]interface{} and assigns it to the ObjectAndItemsNullableProp field.
|
||||||
|
|
||||||
### SetObjectAndItemsNullablePropExplicitNull
|
### SetObjectAndItemsNullablePropExplicitNull
|
||||||
|
|
||||||
|
@ -3,6 +3,5 @@ module github.com/GIT_USER_ID/GIT_REPO_ID
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/antihax/optional v1.0.0
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -19,9 +19,9 @@ type EnumClass string
|
|||||||
|
|
||||||
// List of EnumClass
|
// List of EnumClass
|
||||||
const (
|
const (
|
||||||
ABC EnumClass = "_abc"
|
ENUMCLASS_ABC EnumClass = "_abc"
|
||||||
EFG EnumClass = "-efg"
|
ENUMCLASS_EFG EnumClass = "-efg"
|
||||||
XYZ EnumClass = "(xyz)"
|
ENUMCLASS_XYZ EnumClass = "(xyz)"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NullableEnumClass struct {
|
type NullableEnumClass struct {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,12 +7,11 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NullableClass struct for NullableClass
|
// NullableClass struct for NullableClass
|
||||||
@ -22,12 +21,12 @@ type NullableClass struct {
|
|||||||
BooleanProp *NullableBool `json:"boolean_prop,omitempty"`
|
BooleanProp *NullableBool `json:"boolean_prop,omitempty"`
|
||||||
StringProp *NullableString `json:"string_prop,omitempty"`
|
StringProp *NullableString `json:"string_prop,omitempty"`
|
||||||
DateProp *NullableString `json:"date_prop,omitempty"`
|
DateProp *NullableString `json:"date_prop,omitempty"`
|
||||||
DatetimeProp *NullableTime.Time `json:"datetime_prop,omitempty"`
|
DatetimeProp *NullableTime `json:"datetime_prop,omitempty"`
|
||||||
ArrayNullableProp *Nullable[]map[string]interface{} `json:"array_nullable_prop,omitempty"`
|
ArrayNullableProp *[]map[string]interface{} `json:"array_nullable_prop,omitempty"`
|
||||||
ArrayAndItemsNullableProp *Nullable[]map[string]interface{} `json:"array_and_items_nullable_prop,omitempty"`
|
ArrayAndItemsNullableProp *[]map[string]interface{} `json:"array_and_items_nullable_prop,omitempty"`
|
||||||
ArrayItemsNullable *[]map[string]interface{} `json:"array_items_nullable,omitempty"`
|
ArrayItemsNullable *[]map[string]interface{} `json:"array_items_nullable,omitempty"`
|
||||||
ObjectNullableProp *NullableMap[string]map[string]interface{} `json:"object_nullable_prop,omitempty"`
|
ObjectNullableProp *map[string]map[string]interface{} `json:"object_nullable_prop,omitempty"`
|
||||||
ObjectAndItemsNullableProp *NullableMap[string]map[string]interface{} `json:"object_and_items_nullable_prop,omitempty"`
|
ObjectAndItemsNullableProp *map[string]map[string]interface{} `json:"object_and_items_nullable_prop,omitempty"`
|
||||||
ObjectItemsNullable *map[string]map[string]interface{} `json:"object_items_nullable,omitempty"`
|
ObjectItemsNullable *map[string]map[string]interface{} `json:"object_items_nullable,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,9 +196,9 @@ func (o *NullableClass) SetDateProp(v NullableString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetDatetimeProp returns the DatetimeProp field value if set, zero value otherwise.
|
// GetDatetimeProp returns the DatetimeProp field value if set, zero value otherwise.
|
||||||
func (o *NullableClass) GetDatetimeProp() NullableTime.Time {
|
func (o *NullableClass) GetDatetimeProp() NullableTime {
|
||||||
if o == nil || o.DatetimeProp == nil {
|
if o == nil || o.DatetimeProp == nil {
|
||||||
var ret NullableTime.Time
|
var ret NullableTime
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
return *o.DatetimeProp
|
return *o.DatetimeProp
|
||||||
@ -207,9 +206,9 @@ func (o *NullableClass) GetDatetimeProp() NullableTime.Time {
|
|||||||
|
|
||||||
// GetDatetimePropOk returns a tuple with the DatetimeProp field value if set, zero value otherwise
|
// GetDatetimePropOk returns a tuple with the DatetimeProp field value if set, zero value otherwise
|
||||||
// and a boolean to check if the value has been set.
|
// and a boolean to check if the value has been set.
|
||||||
func (o *NullableClass) GetDatetimePropOk() (NullableTime.Time, bool) {
|
func (o *NullableClass) GetDatetimePropOk() (NullableTime, bool) {
|
||||||
if o == nil || o.DatetimeProp == nil {
|
if o == nil || o.DatetimeProp == nil {
|
||||||
var ret NullableTime.Time
|
var ret NullableTime
|
||||||
return ret, false
|
return ret, false
|
||||||
}
|
}
|
||||||
return *o.DatetimeProp, true
|
return *o.DatetimeProp, true
|
||||||
@ -224,15 +223,15 @@ func (o *NullableClass) HasDatetimeProp() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDatetimeProp gets a reference to the given NullableTime.Time and assigns it to the DatetimeProp field.
|
// SetDatetimeProp gets a reference to the given NullableTime and assigns it to the DatetimeProp field.
|
||||||
func (o *NullableClass) SetDatetimeProp(v NullableTime.Time) {
|
func (o *NullableClass) SetDatetimeProp(v NullableTime) {
|
||||||
o.DatetimeProp = &v
|
o.DatetimeProp = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetArrayNullableProp returns the ArrayNullableProp field value if set, zero value otherwise.
|
// GetArrayNullableProp returns the ArrayNullableProp field value if set, zero value otherwise.
|
||||||
func (o *NullableClass) GetArrayNullableProp() Nullable[]map[string]interface{} {
|
func (o *NullableClass) GetArrayNullableProp() []map[string]interface{} {
|
||||||
if o == nil || o.ArrayNullableProp == nil {
|
if o == nil || o.ArrayNullableProp == nil {
|
||||||
var ret Nullable[]map[string]interface{}
|
var ret []map[string]interface{}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
return *o.ArrayNullableProp
|
return *o.ArrayNullableProp
|
||||||
@ -240,9 +239,9 @@ func (o *NullableClass) GetArrayNullableProp() Nullable[]map[string]interface{}
|
|||||||
|
|
||||||
// GetArrayNullablePropOk returns a tuple with the ArrayNullableProp field value if set, zero value otherwise
|
// GetArrayNullablePropOk returns a tuple with the ArrayNullableProp field value if set, zero value otherwise
|
||||||
// and a boolean to check if the value has been set.
|
// and a boolean to check if the value has been set.
|
||||||
func (o *NullableClass) GetArrayNullablePropOk() (Nullable[]map[string]interface{}, bool) {
|
func (o *NullableClass) GetArrayNullablePropOk() ([]map[string]interface{}, bool) {
|
||||||
if o == nil || o.ArrayNullableProp == nil {
|
if o == nil || o.ArrayNullableProp == nil {
|
||||||
var ret Nullable[]map[string]interface{}
|
var ret []map[string]interface{}
|
||||||
return ret, false
|
return ret, false
|
||||||
}
|
}
|
||||||
return *o.ArrayNullableProp, true
|
return *o.ArrayNullableProp, true
|
||||||
@ -257,15 +256,15 @@ func (o *NullableClass) HasArrayNullableProp() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetArrayNullableProp gets a reference to the given Nullable[]map[string]interface{} and assigns it to the ArrayNullableProp field.
|
// SetArrayNullableProp gets a reference to the given []map[string]interface{} and assigns it to the ArrayNullableProp field.
|
||||||
func (o *NullableClass) SetArrayNullableProp(v Nullable[]map[string]interface{}) {
|
func (o *NullableClass) SetArrayNullableProp(v []map[string]interface{}) {
|
||||||
o.ArrayNullableProp = &v
|
o.ArrayNullableProp = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetArrayAndItemsNullableProp returns the ArrayAndItemsNullableProp field value if set, zero value otherwise.
|
// GetArrayAndItemsNullableProp returns the ArrayAndItemsNullableProp field value if set, zero value otherwise.
|
||||||
func (o *NullableClass) GetArrayAndItemsNullableProp() Nullable[]map[string]interface{} {
|
func (o *NullableClass) GetArrayAndItemsNullableProp() []map[string]interface{} {
|
||||||
if o == nil || o.ArrayAndItemsNullableProp == nil {
|
if o == nil || o.ArrayAndItemsNullableProp == nil {
|
||||||
var ret Nullable[]map[string]interface{}
|
var ret []map[string]interface{}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
return *o.ArrayAndItemsNullableProp
|
return *o.ArrayAndItemsNullableProp
|
||||||
@ -273,9 +272,9 @@ func (o *NullableClass) GetArrayAndItemsNullableProp() Nullable[]map[string]inte
|
|||||||
|
|
||||||
// GetArrayAndItemsNullablePropOk returns a tuple with the ArrayAndItemsNullableProp field value if set, zero value otherwise
|
// GetArrayAndItemsNullablePropOk returns a tuple with the ArrayAndItemsNullableProp field value if set, zero value otherwise
|
||||||
// and a boolean to check if the value has been set.
|
// and a boolean to check if the value has been set.
|
||||||
func (o *NullableClass) GetArrayAndItemsNullablePropOk() (Nullable[]map[string]interface{}, bool) {
|
func (o *NullableClass) GetArrayAndItemsNullablePropOk() ([]map[string]interface{}, bool) {
|
||||||
if o == nil || o.ArrayAndItemsNullableProp == nil {
|
if o == nil || o.ArrayAndItemsNullableProp == nil {
|
||||||
var ret Nullable[]map[string]interface{}
|
var ret []map[string]interface{}
|
||||||
return ret, false
|
return ret, false
|
||||||
}
|
}
|
||||||
return *o.ArrayAndItemsNullableProp, true
|
return *o.ArrayAndItemsNullableProp, true
|
||||||
@ -290,8 +289,8 @@ func (o *NullableClass) HasArrayAndItemsNullableProp() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetArrayAndItemsNullableProp gets a reference to the given Nullable[]map[string]interface{} and assigns it to the ArrayAndItemsNullableProp field.
|
// SetArrayAndItemsNullableProp gets a reference to the given []map[string]interface{} and assigns it to the ArrayAndItemsNullableProp field.
|
||||||
func (o *NullableClass) SetArrayAndItemsNullableProp(v Nullable[]map[string]interface{}) {
|
func (o *NullableClass) SetArrayAndItemsNullableProp(v []map[string]interface{}) {
|
||||||
o.ArrayAndItemsNullableProp = &v
|
o.ArrayAndItemsNullableProp = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,9 +328,9 @@ func (o *NullableClass) SetArrayItemsNullable(v []map[string]interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetObjectNullableProp returns the ObjectNullableProp field value if set, zero value otherwise.
|
// GetObjectNullableProp returns the ObjectNullableProp field value if set, zero value otherwise.
|
||||||
func (o *NullableClass) GetObjectNullableProp() NullableMap[string]map[string]interface{} {
|
func (o *NullableClass) GetObjectNullableProp() map[string]map[string]interface{} {
|
||||||
if o == nil || o.ObjectNullableProp == nil {
|
if o == nil || o.ObjectNullableProp == nil {
|
||||||
var ret NullableMap[string]map[string]interface{}
|
var ret map[string]map[string]interface{}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
return *o.ObjectNullableProp
|
return *o.ObjectNullableProp
|
||||||
@ -339,9 +338,9 @@ func (o *NullableClass) GetObjectNullableProp() NullableMap[string]map[string]in
|
|||||||
|
|
||||||
// GetObjectNullablePropOk returns a tuple with the ObjectNullableProp field value if set, zero value otherwise
|
// GetObjectNullablePropOk returns a tuple with the ObjectNullableProp field value if set, zero value otherwise
|
||||||
// and a boolean to check if the value has been set.
|
// and a boolean to check if the value has been set.
|
||||||
func (o *NullableClass) GetObjectNullablePropOk() (NullableMap[string]map[string]interface{}, bool) {
|
func (o *NullableClass) GetObjectNullablePropOk() (map[string]map[string]interface{}, bool) {
|
||||||
if o == nil || o.ObjectNullableProp == nil {
|
if o == nil || o.ObjectNullableProp == nil {
|
||||||
var ret NullableMap[string]map[string]interface{}
|
var ret map[string]map[string]interface{}
|
||||||
return ret, false
|
return ret, false
|
||||||
}
|
}
|
||||||
return *o.ObjectNullableProp, true
|
return *o.ObjectNullableProp, true
|
||||||
@ -356,15 +355,15 @@ func (o *NullableClass) HasObjectNullableProp() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetObjectNullableProp gets a reference to the given NullableMap[string]map[string]interface{} and assigns it to the ObjectNullableProp field.
|
// SetObjectNullableProp gets a reference to the given map[string]map[string]interface{} and assigns it to the ObjectNullableProp field.
|
||||||
func (o *NullableClass) SetObjectNullableProp(v NullableMap[string]map[string]interface{}) {
|
func (o *NullableClass) SetObjectNullableProp(v map[string]map[string]interface{}) {
|
||||||
o.ObjectNullableProp = &v
|
o.ObjectNullableProp = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetObjectAndItemsNullableProp returns the ObjectAndItemsNullableProp field value if set, zero value otherwise.
|
// GetObjectAndItemsNullableProp returns the ObjectAndItemsNullableProp field value if set, zero value otherwise.
|
||||||
func (o *NullableClass) GetObjectAndItemsNullableProp() NullableMap[string]map[string]interface{} {
|
func (o *NullableClass) GetObjectAndItemsNullableProp() map[string]map[string]interface{} {
|
||||||
if o == nil || o.ObjectAndItemsNullableProp == nil {
|
if o == nil || o.ObjectAndItemsNullableProp == nil {
|
||||||
var ret NullableMap[string]map[string]interface{}
|
var ret map[string]map[string]interface{}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
return *o.ObjectAndItemsNullableProp
|
return *o.ObjectAndItemsNullableProp
|
||||||
@ -372,9 +371,9 @@ func (o *NullableClass) GetObjectAndItemsNullableProp() NullableMap[string]map[s
|
|||||||
|
|
||||||
// GetObjectAndItemsNullablePropOk returns a tuple with the ObjectAndItemsNullableProp field value if set, zero value otherwise
|
// GetObjectAndItemsNullablePropOk returns a tuple with the ObjectAndItemsNullableProp field value if set, zero value otherwise
|
||||||
// and a boolean to check if the value has been set.
|
// and a boolean to check if the value has been set.
|
||||||
func (o *NullableClass) GetObjectAndItemsNullablePropOk() (NullableMap[string]map[string]interface{}, bool) {
|
func (o *NullableClass) GetObjectAndItemsNullablePropOk() (map[string]map[string]interface{}, bool) {
|
||||||
if o == nil || o.ObjectAndItemsNullableProp == nil {
|
if o == nil || o.ObjectAndItemsNullableProp == nil {
|
||||||
var ret NullableMap[string]map[string]interface{}
|
var ret map[string]map[string]interface{}
|
||||||
return ret, false
|
return ret, false
|
||||||
}
|
}
|
||||||
return *o.ObjectAndItemsNullableProp, true
|
return *o.ObjectAndItemsNullableProp, true
|
||||||
@ -389,8 +388,8 @@ func (o *NullableClass) HasObjectAndItemsNullableProp() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetObjectAndItemsNullableProp gets a reference to the given NullableMap[string]map[string]interface{} and assigns it to the ObjectAndItemsNullableProp field.
|
// SetObjectAndItemsNullableProp gets a reference to the given map[string]map[string]interface{} and assigns it to the ObjectAndItemsNullableProp field.
|
||||||
func (o *NullableClass) SetObjectAndItemsNullableProp(v NullableMap[string]map[string]interface{}) {
|
func (o *NullableClass) SetObjectAndItemsNullableProp(v map[string]map[string]interface{}) {
|
||||||
o.ObjectAndItemsNullableProp = &v
|
o.ObjectAndItemsNullableProp = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -19,9 +19,9 @@ type OuterEnum string
|
|||||||
|
|
||||||
// List of OuterEnum
|
// List of OuterEnum
|
||||||
const (
|
const (
|
||||||
PLACED OuterEnum = "placed"
|
OUTERENUM_PLACED OuterEnum = "placed"
|
||||||
APPROVED OuterEnum = "approved"
|
OUTERENUM_APPROVED OuterEnum = "approved"
|
||||||
DELIVERED OuterEnum = "delivered"
|
OUTERENUM_DELIVERED OuterEnum = "delivered"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NullableOuterEnum struct {
|
type NullableOuterEnum struct {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -19,9 +19,9 @@ type OuterEnumDefaultValue string
|
|||||||
|
|
||||||
// List of OuterEnumDefaultValue
|
// List of OuterEnumDefaultValue
|
||||||
const (
|
const (
|
||||||
PLACED OuterEnumDefaultValue = "placed"
|
OUTERENUMDEFAULTVALUE_PLACED OuterEnumDefaultValue = "placed"
|
||||||
APPROVED OuterEnumDefaultValue = "approved"
|
OUTERENUMDEFAULTVALUE_APPROVED OuterEnumDefaultValue = "approved"
|
||||||
DELIVERED OuterEnumDefaultValue = "delivered"
|
OUTERENUMDEFAULTVALUE_DELIVERED OuterEnumDefaultValue = "delivered"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NullableOuterEnumDefaultValue struct {
|
type NullableOuterEnumDefaultValue struct {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -19,9 +19,9 @@ type OuterEnumInteger int32
|
|||||||
|
|
||||||
// List of OuterEnumInteger
|
// List of OuterEnumInteger
|
||||||
const (
|
const (
|
||||||
_0 OuterEnumInteger = 0
|
OUTERENUMINTEGER__0 OuterEnumInteger = 0
|
||||||
_1 OuterEnumInteger = 1
|
OUTERENUMINTEGER__1 OuterEnumInteger = 1
|
||||||
_2 OuterEnumInteger = 2
|
OUTERENUMINTEGER__2 OuterEnumInteger = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
type NullableOuterEnumInteger struct {
|
type NullableOuterEnumInteger struct {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -19,9 +19,9 @@ type OuterEnumIntegerDefaultValue int32
|
|||||||
|
|
||||||
// List of OuterEnumIntegerDefaultValue
|
// List of OuterEnumIntegerDefaultValue
|
||||||
const (
|
const (
|
||||||
_0 OuterEnumIntegerDefaultValue = 0
|
OUTERENUMINTEGERDEFAULTVALUE__0 OuterEnumIntegerDefaultValue = 0
|
||||||
_1 OuterEnumIntegerDefaultValue = 1
|
OUTERENUMINTEGERDEFAULTVALUE__1 OuterEnumIntegerDefaultValue = 1
|
||||||
_2 OuterEnumIntegerDefaultValue = 2
|
OUTERENUMINTEGERDEFAULTVALUE__2 OuterEnumIntegerDefaultValue = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
type NullableOuterEnumIntegerDefaultValue struct {
|
type NullableOuterEnumIntegerDefaultValue struct {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
292
samples/openapi3/client/petstore/go-experimental/pet_api_test.go
Normal file
292
samples/openapi3/client/petstore/go-experimental/pet_api_test.go
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
sw "./go-petstore"
|
||||||
|
)
|
||||||
|
|
||||||
|
var client *sw.APIClient
|
||||||
|
|
||||||
|
const testHost = "petstore.swagger.io:80"
|
||||||
|
const testScheme = "http"
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
cfg := sw.NewConfiguration()
|
||||||
|
cfg.AddDefaultHeader("testheader", "testvalue")
|
||||||
|
cfg.Host = testHost
|
||||||
|
cfg.Scheme = testScheme
|
||||||
|
client = sw.NewAPIClient(cfg)
|
||||||
|
retCode := m.Run()
|
||||||
|
os.Exit(retCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAddPet(t *testing.T) {
|
||||||
|
newPet := (sw.Pet{Id: sw.PtrInt64(12830), Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
|
||||||
|
Tags: &[]sw.Tag{sw.Tag{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(context.Background()).Pet(newPet).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFindPetsByStatusWithMissingParam(t *testing.T) {
|
||||||
|
_, r, err := client.PetApi.FindPetsByStatus(context.Background()).Status(nil).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while testing TestFindPetsByStatusWithMissingParam: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetPetById(t *testing.T) {
|
||||||
|
isPetCorrect(t, 12830, "gopher", "pending")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetPetByIdWithInvalidID(t *testing.T) {
|
||||||
|
resp, r, err := client.PetApi.GetPetById(context.Background(), 999999999).Execute()
|
||||||
|
if r != nil && r.StatusCode == 404 {
|
||||||
|
assertedError, ok := err.(sw.GenericOpenAPIError)
|
||||||
|
a := assert.New(t)
|
||||||
|
a.True(ok)
|
||||||
|
a.Contains(string(assertedError.Body()), "type")
|
||||||
|
|
||||||
|
a.Contains(assertedError.Error(), "Not Found")
|
||||||
|
} else if err != nil {
|
||||||
|
t.Fatalf("Error while getting pet by invalid id: %v", err)
|
||||||
|
t.Log(r)
|
||||||
|
} else {
|
||||||
|
t.Log(resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdatePetWithForm(t *testing.T) {
|
||||||
|
r, err := client.PetApi.UpdatePetWithForm(context.Background(), 12830).Name("golang").Status("available").Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while updating pet by id: %v", err)
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the pet with id 12830 from server to verify the update
|
||||||
|
isPetCorrect(t, 12830, "golang", "available")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFindPetsByTag(t *testing.T) {
|
||||||
|
var found = false
|
||||||
|
resp, r, err := client.PetApi.FindPetsByTags(context.Background()).Tags([]string{"tag2"}).Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while getting pet by tag: %v", err)
|
||||||
|
t.Log(r)
|
||||||
|
} else {
|
||||||
|
if len(resp) == 0 {
|
||||||
|
t.Errorf("Error no pets returned")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
assert := assert.New(t)
|
||||||
|
for i := 0; i < len(resp); i++ {
|
||||||
|
if *resp[i].Id == 12830 {
|
||||||
|
assert.Equal(*resp[i].Status, "available", "Pet status should be `pending`")
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if found == false {
|
||||||
|
t.Errorf("Error while getting pet by tag could not find 12830")
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFindPetsByStatus(t *testing.T) {
|
||||||
|
resp, r, err := client.PetApi.FindPetsByStatus(context.Background()).Status([]string{"available"}).Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while getting pet by id: %v", err)
|
||||||
|
t.Log(r)
|
||||||
|
} else {
|
||||||
|
if len(resp) == 0 {
|
||||||
|
t.Errorf("Error no pets returned")
|
||||||
|
} else {
|
||||||
|
assert := assert.New(t)
|
||||||
|
for i := 0; i < len(resp); i++ {
|
||||||
|
assert.Equal(*resp[i].Status, "available", "Pet status should be `available`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUploadFile(t *testing.T) {
|
||||||
|
file, err1 := os.Open("testfiles/foo.png")
|
||||||
|
if err1 != nil {
|
||||||
|
t.Fatalf("Error opening file: %v", err1)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, r, err := client.PetApi.UploadFile(context.Background(), 12830).AdditionalMetadata("golang").File(file).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while uploading file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUploadFileRequired(t *testing.T) {
|
||||||
|
return // remove when server supports this endpoint
|
||||||
|
file, err1 := os.Open("testfiles/foo.png")
|
||||||
|
if err1 != nil {
|
||||||
|
t.Fatalf("Error opening file: %v", err1)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, r, err := client.PetApi.UploadFileWithRequiredFile(context.Background(), 12830).RequiredFile(file).AdditionalMetadata("golang").Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while uploading file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeletePet(t *testing.T) {
|
||||||
|
r, err := client.PetApi.DeletePet(context.Background(), 12830).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Test we can concurrently create, retrieve, update, and delete.
|
||||||
|
func TestConcurrency(t *testing.T) {
|
||||||
|
errc := make(chan error)
|
||||||
|
|
||||||
|
newPets := []sw.Pet{
|
||||||
|
sw.Pet{Id: 912345, Name: "gopherFred", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"},
|
||||||
|
sw.Pet{Id: 912346, Name: "gopherDan", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "active"},
|
||||||
|
sw.Pet{Id: 912347, Name: "gopherRick", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "mia"},
|
||||||
|
sw.Pet{Id: 912348, Name: "gopherJohn", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "active"},
|
||||||
|
sw.Pet{Id: 912349, Name: "gopherAlf", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"},
|
||||||
|
sw.Pet{Id: 912350, Name: "gopherRob", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"},
|
||||||
|
sw.Pet{Id: 912351, Name: "gopherIan", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "active"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the pets.
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(newPet sw.Pet) {
|
||||||
|
r, err := client.PetApi.AddPet(nil, newPet)
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
errc <- err
|
||||||
|
}(pet)
|
||||||
|
}
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
|
||||||
|
// Verify they are correct.
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(pet sw.Pet) {
|
||||||
|
isPetCorrect(t, pet.Id, pet.Name, pet.Status)
|
||||||
|
errc <- nil
|
||||||
|
}(pet)
|
||||||
|
}
|
||||||
|
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
|
||||||
|
// Update all to active with the name gopherDan
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(id int64) {
|
||||||
|
r, err := client.PetApi.UpdatePet(nil, sw.Pet{Id: (int64)(id), Name: "gopherDan", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "active"})
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
errc <- err
|
||||||
|
}(pet.Id)
|
||||||
|
}
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
|
||||||
|
// Verify they are correct.
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(pet sw.Pet) {
|
||||||
|
isPetCorrect(t, pet.Id, "gopherDan", "active")
|
||||||
|
errc <- nil
|
||||||
|
}(pet)
|
||||||
|
}
|
||||||
|
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
|
||||||
|
// Delete them all.
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(id int64) {
|
||||||
|
deletePet(t, (int64)(id))
|
||||||
|
errc <- nil
|
||||||
|
}(pet.Id)
|
||||||
|
}
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
func waitOnFunctions(t *testing.T, errc chan error, n int) {
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
err := <-errc
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error performing concurrent test: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func deletePet(t *testing.T, id int64) {
|
||||||
|
r, err := client.PetApi.DeletePet(context.Background(), id).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func isPetCorrect(t *testing.T, id int64, name string, status string) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
resp, r, err := client.PetApi.GetPetById(context.Background(), id).Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while getting pet by id: %v", err)
|
||||||
|
} else {
|
||||||
|
assert.Equal(*resp.Id, int64(id), "Pet id should be equal")
|
||||||
|
assert.Equal(resp.Name, name, fmt.Sprintf("Pet name should be %s", name))
|
||||||
|
assert.Equal(*resp.Status, status, fmt.Sprintf("Pet status should be %s", status))
|
||||||
|
|
||||||
|
//t.Log(resp)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
89
samples/openapi3/client/petstore/go-experimental/pom.xml
Normal file
89
samples/openapi3/client/petstore/go-experimental/pom.xml
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>GoExperimentalOAS3Petstore</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<name>Go Experimental OpenAPI3 Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>go-get-testify</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>get</argument>
|
||||||
|
<argument>github.com/stretchr/testify/assert</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>go-get-oauth2</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>get</argument>
|
||||||
|
<argument>golang.org/x/oauth2</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>go-get-context</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>get</argument>
|
||||||
|
<argument>golang.org/x/net/context</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>go-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
<argument>-v</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,37 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"regexp"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
sw "./go-petstore"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPlaceOrder(t *testing.T) {
|
||||||
|
newOrder := sw.Order{
|
||||||
|
Id: sw.PtrInt64(0),
|
||||||
|
PetId: sw.PtrInt64(0),
|
||||||
|
Quantity: sw.PtrInt32(0),
|
||||||
|
ShipDate: sw.PtrTime(time.Now().UTC()),
|
||||||
|
Status: sw.PtrString("placed"),
|
||||||
|
Complete: sw.PtrBool(false)}
|
||||||
|
|
||||||
|
_, r, err := client.StoreApi.PlaceOrder(context.Background()).Order(newOrder).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
// Skip parsing time error due to error in Petstore Test Server
|
||||||
|
// https://github.com/OpenAPITools/openapi-generator/issues/1292
|
||||||
|
if regexp.
|
||||||
|
MustCompile(`^parsing time.+cannot parse "\+0000"" as "Z07:00"$`).
|
||||||
|
MatchString(err.Error()) {
|
||||||
|
t.Log("Skipping error for parsing time with `+0000` UTC offset as Petstore Test Server does not return valid RFC 3339 datetime")
|
||||||
|
} else {
|
||||||
|
t.Fatalf("Error while placing order: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
@ -0,0 +1,153 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
sw "./go-petstore"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCreateUser(t *testing.T) {
|
||||||
|
newUser := sw.User{
|
||||||
|
Id: sw.PtrInt64(1000),
|
||||||
|
FirstName: sw.PtrString("gopher"),
|
||||||
|
LastName: sw.PtrString("lang"),
|
||||||
|
Username: sw.PtrString("gopher"),
|
||||||
|
Password: sw.PtrString("lang"),
|
||||||
|
Email: sw.PtrString("lang@test.com"),
|
||||||
|
Phone: sw.PtrString("5101112222"),
|
||||||
|
UserStatus: sw.PtrInt32(1)}
|
||||||
|
|
||||||
|
apiResponse, err := client.UserApi.CreateUser(context.Background()).User(newUser).Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding user: %v", err)
|
||||||
|
}
|
||||||
|
if apiResponse.StatusCode != 200 {
|
||||||
|
t.Log(apiResponse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//adding x to skip the test, currently it is failing
|
||||||
|
func TestCreateUsersWithArrayInput(t *testing.T) {
|
||||||
|
newUsers := []sw.User{
|
||||||
|
sw.User{
|
||||||
|
Id: sw.PtrInt64(1001),
|
||||||
|
FirstName: sw.PtrString("gopher1"),
|
||||||
|
LastName: sw.PtrString("lang1"),
|
||||||
|
Username: sw.PtrString("gopher1"),
|
||||||
|
Password: sw.PtrString("lang1"),
|
||||||
|
Email: sw.PtrString("lang1@test.com"),
|
||||||
|
Phone: sw.PtrString("5101112222"),
|
||||||
|
UserStatus: sw.PtrInt32(1),
|
||||||
|
},
|
||||||
|
sw.User{
|
||||||
|
Id: sw.PtrInt64(1002),
|
||||||
|
FirstName: sw.PtrString("gopher2"),
|
||||||
|
LastName: sw.PtrString("lang2"),
|
||||||
|
Username: sw.PtrString("gopher2"),
|
||||||
|
Password: sw.PtrString("lang2"),
|
||||||
|
Email: sw.PtrString("lang2@test.com"),
|
||||||
|
Phone: sw.PtrString("5101112222"),
|
||||||
|
UserStatus: sw.PtrInt32(1),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse, err := client.UserApi.CreateUsersWithArrayInput(context.Background()).User(newUsers).Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding users: %v", err)
|
||||||
|
}
|
||||||
|
if apiResponse.StatusCode != 200 {
|
||||||
|
t.Log(apiResponse)
|
||||||
|
}
|
||||||
|
|
||||||
|
//tear down
|
||||||
|
_, err1 := client.UserApi.DeleteUser(context.Background(), "gopher1").Execute()
|
||||||
|
if err1 != nil {
|
||||||
|
t.Errorf("Error while deleting user")
|
||||||
|
t.Log(err1)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err2 := client.UserApi.DeleteUser(context.Background(), "gopher2").Execute()
|
||||||
|
if err2 != nil {
|
||||||
|
t.Errorf("Error while deleting user")
|
||||||
|
t.Log(err2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetUserByName(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
resp, apiResponse, err := client.UserApi.GetUserByName(context.Background(), "gopher").Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while getting user by id: %v", err)
|
||||||
|
} else {
|
||||||
|
assert.Equal(*resp.Id, int64(1000), "User id should be equal")
|
||||||
|
assert.Equal(*resp.Username, "gopher", "User name should be gopher")
|
||||||
|
assert.Equal(*resp.LastName, "lang", "Last name should be lang")
|
||||||
|
//t.Log(resp)
|
||||||
|
}
|
||||||
|
if apiResponse.StatusCode != 200 {
|
||||||
|
t.Log(apiResponse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetUserByNameWithInvalidID(t *testing.T) {
|
||||||
|
resp, apiResponse, err := client.UserApi.GetUserByName(context.Background(), "999999999").Execute()
|
||||||
|
if apiResponse != nil && apiResponse.StatusCode == 404 {
|
||||||
|
return // This is a pass condition. API will return with a 404 error.
|
||||||
|
} else if err != nil {
|
||||||
|
t.Fatalf("Error while getting user by invalid id: %v", err)
|
||||||
|
t.Log(apiResponse)
|
||||||
|
} else {
|
||||||
|
t.Log(resp)
|
||||||
|
}
|
||||||
|
if apiResponse.StatusCode != 200 {
|
||||||
|
t.Log(apiResponse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdateUser(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
newUser := sw.User{
|
||||||
|
Id: sw.PtrInt64(1000),
|
||||||
|
FirstName: sw.PtrString("gopher20"),
|
||||||
|
LastName: sw.PtrString("lang20"),
|
||||||
|
Username: sw.PtrString("gopher"),
|
||||||
|
Password: sw.PtrString("lang"),
|
||||||
|
Email: sw.PtrString("lang@test.com"),
|
||||||
|
Phone: sw.PtrString("5101112222"),
|
||||||
|
UserStatus: sw.PtrInt32(1)}
|
||||||
|
|
||||||
|
apiResponse, err := client.UserApi.UpdateUser(context.Background(), "gopher").User(newUser).Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting user by id: %v", err)
|
||||||
|
}
|
||||||
|
if apiResponse.StatusCode != 200 {
|
||||||
|
t.Log(apiResponse)
|
||||||
|
}
|
||||||
|
|
||||||
|
//verify changings are correct
|
||||||
|
resp, apiResponse, err := client.UserApi.GetUserByName(context.Background(), "gopher").Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while getting user by id: %v", err)
|
||||||
|
} else {
|
||||||
|
assert.Equal(*resp.Id, int64(1000), "User id should be equal")
|
||||||
|
assert.Equal(*resp.FirstName, "gopher20", "User name should be gopher")
|
||||||
|
assert.Equal(*resp.Password, "lang", "User name should be the same")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeleteUser(t *testing.T) {
|
||||||
|
apiResponse, err := client.UserApi.DeleteUser(context.Background(), "gopher").Execute()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting user: %v", err)
|
||||||
|
}
|
||||||
|
if apiResponse.StatusCode != 200 {
|
||||||
|
t.Log(apiResponse)
|
||||||
|
}
|
||||||
|
}
|
254
samples/openapi3/client/petstore/go/auth_test.go
Normal file
254
samples/openapi3/client/petstore/go/auth_test.go
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/oauth2"
|
||||||
|
|
||||||
|
sw "./go-petstore"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOAuth2(t *testing.T) {
|
||||||
|
// Setup some fake oauth2 configuration
|
||||||
|
cfg := &oauth2.Config{
|
||||||
|
ClientID: "1234567",
|
||||||
|
ClientSecret: "SuperSecret",
|
||||||
|
Endpoint: oauth2.Endpoint{
|
||||||
|
AuthURL: "https://devnull",
|
||||||
|
TokenURL: "https://devnull",
|
||||||
|
},
|
||||||
|
RedirectURL: "https://devnull",
|
||||||
|
}
|
||||||
|
|
||||||
|
// and a fake token
|
||||||
|
tok := oauth2.Token{
|
||||||
|
AccessToken: "FAKE",
|
||||||
|
RefreshToken: "So Fake",
|
||||||
|
Expiry: time.Now().Add(time.Hour * 100000),
|
||||||
|
TokenType: "Bearer",
|
||||||
|
}
|
||||||
|
|
||||||
|
// then a fake tokenSource
|
||||||
|
tokenSource := cfg.TokenSource(createContext(nil), &tok)
|
||||||
|
auth := context.WithValue(context.Background(), sw.ContextOAuth2, tokenSource)
|
||||||
|
|
||||||
|
newPet := (sw.Pet{Id: 12992, Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending", Tags: []sw.Tag{sw.Tag{Id: 1, Name: "tag2"}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(context.Background(), newPet)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992, nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
|
||||||
|
if !strings.Contains((string)(reqb), "Authorization: Bearer FAKE") {
|
||||||
|
t.Errorf("OAuth2 Authentication is missing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBasicAuth(t *testing.T) {
|
||||||
|
|
||||||
|
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
|
||||||
|
UserName: "fakeUser",
|
||||||
|
Password: "f4k3p455",
|
||||||
|
})
|
||||||
|
|
||||||
|
newPet := (sw.Pet{Id: 12992, Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending", Tags: []sw.Tag{sw.Tag{Id: 1, Name: "tag2"}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(auth, newPet)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992, nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Authorization: Basic ZmFrZVVzZXI6ZjRrM3A0NTU") {
|
||||||
|
t.Errorf("Basic Authentication is missing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAccessToken(t *testing.T) {
|
||||||
|
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "TESTFAKEACCESSTOKENISFAKE")
|
||||||
|
|
||||||
|
newPet := (sw.Pet{Id: 12992, Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending", Tags: []sw.Tag{sw.Tag{Id: 1, Name: "tag2"}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(nil, newPet)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992, nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Authorization: Bearer TESTFAKEACCESSTOKENISFAKE") {
|
||||||
|
t.Errorf("AccessToken Authentication is missing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAPIKeyNoPrefix(t *testing.T) {
|
||||||
|
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{Key: "TEST123"})
|
||||||
|
|
||||||
|
newPet := (sw.Pet{Id: 12992, Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending", Tags: []sw.Tag{sw.Tag{Id: 1, Name: "tag2"}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(context.Background(), newPet)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, r, err = client.PetApi.GetPetById(auth, 12992)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Api_key: TEST123") {
|
||||||
|
t.Errorf("APIKey Authentication is missing")
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAPIKeyWithPrefix(t *testing.T) {
|
||||||
|
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{Key: "TEST123", Prefix: "Bearer"})
|
||||||
|
|
||||||
|
newPet := (sw.Pet{Id: 12992, Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending", Tags: []sw.Tag{sw.Tag{Id: 1, Name: "tag2"}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(nil, newPet)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, r, err = client.PetApi.GetPetById(auth, 12992)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Api_key: Bearer TEST123") {
|
||||||
|
t.Errorf("APIKey Authentication is missing")
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(auth, 12992, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDefaultHeader(t *testing.T) {
|
||||||
|
|
||||||
|
newPet := (sw.Pet{Id: 12992, Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending", Tags: []sw.Tag{sw.Tag{Id: 1, Name: "tag2"}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(context.Background(), newPet)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err = client.PetApi.DeletePet(context.Background(), 12992, nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
reqb, _ := httputil.DumpRequest(r.Request, true)
|
||||||
|
if !strings.Contains((string)(reqb), "Testheader: testvalue") {
|
||||||
|
t.Errorf("Default Header is missing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHostOverride(t *testing.T) {
|
||||||
|
_, r, err := client.PetApi.FindPetsByStatus(context.Background(), nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while finding pets by status: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Request.URL.Host != testHost {
|
||||||
|
t.Errorf("Request Host is %v, expected %v", r.Request.Host, testHost)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSchemeOverride(t *testing.T) {
|
||||||
|
_, r, err := client.PetApi.FindPetsByStatus(context.Background(), nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while finding pets by status: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Request.URL.Scheme != testScheme {
|
||||||
|
t.Errorf("Request Scheme is %v, expected %v", r.Request.URL.Scheme, testScheme)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add custom clients to the context.
|
||||||
|
func createContext(httpClient *http.Client) context.Context {
|
||||||
|
parent := oauth2.NoContext
|
||||||
|
ctx := context.WithValue(parent, oauth2.HTTPClient, httpClient)
|
||||||
|
return ctx
|
||||||
|
}
|
28
samples/openapi3/client/petstore/go/fake_api_test.go
Normal file
28
samples/openapi3/client/petstore/go/fake_api_test.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
sw "./go-petstore"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestPutBodyWithFileSchema ensures a model with the name 'File'
|
||||||
|
// gets converted properly to the petstore.File struct vs. *os.File
|
||||||
|
// as specified in typeMapping for 'File'.
|
||||||
|
func TestPutBodyWithFileSchema(t *testing.T) {
|
||||||
|
return // early return to test compilation
|
||||||
|
|
||||||
|
schema := sw.FileSchemaTestClass{
|
||||||
|
File: sw.File{SourceURI: "https://example.com/image.png"},
|
||||||
|
Files: []sw.File{{SourceURI: "https://example.com/image.png"}}}
|
||||||
|
|
||||||
|
r, err := client.FakeApi.TestBodyWithFileSchema(context.Background(), schema)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
@ -1236,6 +1236,7 @@ func (a *FakeApiService) TestQueryParameterCollectionFormat(ctx _context.Context
|
|||||||
localVarQueryParams := _neturl.Values{}
|
localVarQueryParams := _neturl.Values{}
|
||||||
localVarFormParams := _neturl.Values{}
|
localVarFormParams := _neturl.Values{}
|
||||||
|
|
||||||
|
{
|
||||||
t:=pipe
|
t:=pipe
|
||||||
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
||||||
s := reflect.ValueOf(t)
|
s := reflect.ValueOf(t)
|
||||||
@ -1245,9 +1246,11 @@ func (a *FakeApiService) TestQueryParameterCollectionFormat(ctx _context.Context
|
|||||||
} else {
|
} else {
|
||||||
localVarQueryParams.Add("pipe", parameterToString(t, "multi"))
|
localVarQueryParams.Add("pipe", parameterToString(t, "multi"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
localVarQueryParams.Add("ioutil", parameterToString(ioutil, "csv"))
|
localVarQueryParams.Add("ioutil", parameterToString(ioutil, "csv"))
|
||||||
localVarQueryParams.Add("http", parameterToString(http, "space"))
|
localVarQueryParams.Add("http", parameterToString(http, "space"))
|
||||||
localVarQueryParams.Add("url", parameterToString(url, "csv"))
|
localVarQueryParams.Add("url", parameterToString(url, "csv"))
|
||||||
|
{
|
||||||
t:=context
|
t:=context
|
||||||
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
if reflect.TypeOf(t).Kind() == reflect.Slice {
|
||||||
s := reflect.ValueOf(t)
|
s := reflect.ValueOf(t)
|
||||||
@ -1257,6 +1260,7 @@ func (a *FakeApiService) TestQueryParameterCollectionFormat(ctx _context.Context
|
|||||||
} else {
|
} else {
|
||||||
localVarQueryParams.Add("context", parameterToString(t, "multi"))
|
localVarQueryParams.Add("context", parameterToString(t, "multi"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHTTPContentTypes := []string{}
|
localVarHTTPContentTypes := []string{}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ type EnumClass string
|
|||||||
|
|
||||||
// List of EnumClass
|
// List of EnumClass
|
||||||
const (
|
const (
|
||||||
ABC EnumClass = "_abc"
|
ENUMCLASS_ABC EnumClass = "_abc"
|
||||||
EFG EnumClass = "-efg"
|
ENUMCLASS_EFG EnumClass = "-efg"
|
||||||
XYZ EnumClass = "(xyz)"
|
ENUMCLASS_XYZ EnumClass = "(xyz)"
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,7 @@ type OuterEnum string
|
|||||||
|
|
||||||
// List of OuterEnum
|
// List of OuterEnum
|
||||||
const (
|
const (
|
||||||
PLACED OuterEnum = "placed"
|
OUTERENUM_PLACED OuterEnum = "placed"
|
||||||
APPROVED OuterEnum = "approved"
|
OUTERENUM_APPROVED OuterEnum = "approved"
|
||||||
DELIVERED OuterEnum = "delivered"
|
OUTERENUM_DELIVERED OuterEnum = "delivered"
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,7 @@ type OuterEnumDefaultValue string
|
|||||||
|
|
||||||
// List of OuterEnumDefaultValue
|
// List of OuterEnumDefaultValue
|
||||||
const (
|
const (
|
||||||
PLACED OuterEnumDefaultValue = "placed"
|
OUTERENUMDEFAULTVALUE_PLACED OuterEnumDefaultValue = "placed"
|
||||||
APPROVED OuterEnumDefaultValue = "approved"
|
OUTERENUMDEFAULTVALUE_APPROVED OuterEnumDefaultValue = "approved"
|
||||||
DELIVERED OuterEnumDefaultValue = "delivered"
|
OUTERENUMDEFAULTVALUE_DELIVERED OuterEnumDefaultValue = "delivered"
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,7 @@ type OuterEnumInteger int32
|
|||||||
|
|
||||||
// List of OuterEnumInteger
|
// List of OuterEnumInteger
|
||||||
const (
|
const (
|
||||||
_0 OuterEnumInteger = 0
|
OUTERENUMINTEGER__0 OuterEnumInteger = 0
|
||||||
_1 OuterEnumInteger = 1
|
OUTERENUMINTEGER__1 OuterEnumInteger = 1
|
||||||
_2 OuterEnumInteger = 2
|
OUTERENUMINTEGER__2 OuterEnumInteger = 2
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,7 @@ type OuterEnumIntegerDefaultValue int32
|
|||||||
|
|
||||||
// List of OuterEnumIntegerDefaultValue
|
// List of OuterEnumIntegerDefaultValue
|
||||||
const (
|
const (
|
||||||
_0 OuterEnumIntegerDefaultValue = 0
|
OUTERENUMINTEGERDEFAULTVALUE__0 OuterEnumIntegerDefaultValue = 0
|
||||||
_1 OuterEnumIntegerDefaultValue = 1
|
OUTERENUMINTEGERDEFAULTVALUE__1 OuterEnumIntegerDefaultValue = 1
|
||||||
_2 OuterEnumIntegerDefaultValue = 2
|
OUTERENUMINTEGERDEFAULTVALUE__2 OuterEnumIntegerDefaultValue = 2
|
||||||
)
|
)
|
||||||
|
303
samples/openapi3/client/petstore/go/pet_api_test.go
Normal file
303
samples/openapi3/client/petstore/go/pet_api_test.go
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/antihax/optional"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
sw "./go-petstore"
|
||||||
|
)
|
||||||
|
|
||||||
|
var client *sw.APIClient
|
||||||
|
|
||||||
|
const testHost = "petstore.swagger.io:80"
|
||||||
|
const testScheme = "http"
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
cfg := sw.NewConfiguration()
|
||||||
|
cfg.AddDefaultHeader("testheader", "testvalue")
|
||||||
|
cfg.Host = testHost
|
||||||
|
cfg.Scheme = testScheme
|
||||||
|
client = sw.NewAPIClient(cfg)
|
||||||
|
retCode := m.Run()
|
||||||
|
os.Exit(retCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAddPet(t *testing.T) {
|
||||||
|
newPet := (sw.Pet{Id: 12830, Name: "gopher",
|
||||||
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending", Tags: []sw.Tag{sw.Tag{Id: 1, Name: "tag2"}}})
|
||||||
|
|
||||||
|
r, err := client.PetApi.AddPet(context.Background(), newPet)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while adding pet: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFindPetsByStatusWithMissingParam(t *testing.T) {
|
||||||
|
_, r, err := client.PetApi.FindPetsByStatus(context.Background(), nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while testing TestFindPetsByStatusWithMissingParam: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetPetById(t *testing.T) {
|
||||||
|
isPetCorrect(t, 12830, "gopher", "pending")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetPetByIdWithInvalidID(t *testing.T) {
|
||||||
|
resp, r, err := client.PetApi.GetPetById(context.Background(), 999999999)
|
||||||
|
if r != nil && r.StatusCode == 404 {
|
||||||
|
assertedError, ok := err.(sw.GenericOpenAPIError)
|
||||||
|
a := assert.New(t)
|
||||||
|
a.True(ok)
|
||||||
|
a.Contains(string(assertedError.Body()), "type")
|
||||||
|
|
||||||
|
a.Contains(assertedError.Error(), "Not Found")
|
||||||
|
} else if err != nil {
|
||||||
|
t.Fatalf("Error while getting pet by invalid id: %v", err)
|
||||||
|
t.Log(r)
|
||||||
|
} else {
|
||||||
|
t.Log(resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdatePetWithForm(t *testing.T) {
|
||||||
|
r, err := client.PetApi.UpdatePetWithForm(context.Background(), 12830, &sw.UpdatePetWithFormOpts{
|
||||||
|
Name: optional.NewString("golang"),
|
||||||
|
Status: optional.NewString("available"),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while updating pet by id: %v", err)
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the pet with id 12830 from server to verify the update
|
||||||
|
isPetCorrect(t, 12830, "golang", "available")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFindPetsByTag(t *testing.T) {
|
||||||
|
var found = false
|
||||||
|
resp, r, err := client.PetApi.FindPetsByTags(context.Background(), []string{"tag2"})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while getting pet by tag: %v", err)
|
||||||
|
t.Log(r)
|
||||||
|
} else {
|
||||||
|
if len(resp) == 0 {
|
||||||
|
t.Errorf("Error no pets returned")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
assert := assert.New(t)
|
||||||
|
for i := 0; i < len(resp); i++ {
|
||||||
|
if resp[i].Id == 12830 {
|
||||||
|
assert.Equal(resp[i].Status, "available", "Pet status should be `pending`")
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if found == false {
|
||||||
|
t.Errorf("Error while getting pet by tag could not find 12830")
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFindPetsByStatus(t *testing.T) {
|
||||||
|
resp, r, err := client.PetApi.FindPetsByStatus(context.Background(), []string{"available"})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while getting pet by id: %v", err)
|
||||||
|
t.Log(r)
|
||||||
|
} else {
|
||||||
|
if len(resp) == 0 {
|
||||||
|
t.Errorf("Error no pets returned")
|
||||||
|
} else {
|
||||||
|
assert := assert.New(t)
|
||||||
|
for i := 0; i < len(resp); i++ {
|
||||||
|
assert.Equal(resp[i].Status, "available", "Pet status should be `available`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUploadFile(t *testing.T) {
|
||||||
|
file, err1 := os.Open("testfiles/foo.png")
|
||||||
|
if err1 != nil {
|
||||||
|
t.Fatalf("Error opening file: %v", err1)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, r, err := client.PetApi.UploadFile(context.Background(), 12830, &sw.UploadFileOpts{
|
||||||
|
AdditionalMetadata: optional.NewString("golang"),
|
||||||
|
File: optional.NewInterface(file),
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while uploading file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUploadFileRequired(t *testing.T) {
|
||||||
|
return // remove when server supports this endpoint
|
||||||
|
file, err1 := os.Open("testfiles/foo.png")
|
||||||
|
if err1 != nil {
|
||||||
|
t.Fatalf("Error opening file: %v", err1)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, r, err := client.PetApi.UploadFileWithRequiredFile(context.Background(), 12830,
|
||||||
|
file,
|
||||||
|
&sw.UploadFileWithRequiredFileOpts{
|
||||||
|
AdditionalMetadata: optional.NewString("golang"),
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while uploading file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeletePet(t *testing.T) {
|
||||||
|
r, err := client.PetApi.DeletePet(context.Background(), 12830, nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Test we can concurrently create, retrieve, update, and delete.
|
||||||
|
func TestConcurrency(t *testing.T) {
|
||||||
|
errc := make(chan error)
|
||||||
|
|
||||||
|
newPets := []sw.Pet{
|
||||||
|
sw.Pet{Id: 912345, Name: "gopherFred", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"},
|
||||||
|
sw.Pet{Id: 912346, Name: "gopherDan", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "active"},
|
||||||
|
sw.Pet{Id: 912347, Name: "gopherRick", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "mia"},
|
||||||
|
sw.Pet{Id: 912348, Name: "gopherJohn", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "active"},
|
||||||
|
sw.Pet{Id: 912349, Name: "gopherAlf", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"},
|
||||||
|
sw.Pet{Id: 912350, Name: "gopherRob", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"},
|
||||||
|
sw.Pet{Id: 912351, Name: "gopherIan", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "active"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the pets.
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(newPet sw.Pet) {
|
||||||
|
r, err := client.PetApi.AddPet(nil, newPet)
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
errc <- err
|
||||||
|
}(pet)
|
||||||
|
}
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
|
||||||
|
// Verify they are correct.
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(pet sw.Pet) {
|
||||||
|
isPetCorrect(t, pet.Id, pet.Name, pet.Status)
|
||||||
|
errc <- nil
|
||||||
|
}(pet)
|
||||||
|
}
|
||||||
|
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
|
||||||
|
// Update all to active with the name gopherDan
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(id int64) {
|
||||||
|
r, err := client.PetApi.UpdatePet(nil, sw.Pet{Id: (int64)(id), Name: "gopherDan", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "active"})
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
errc <- err
|
||||||
|
}(pet.Id)
|
||||||
|
}
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
|
||||||
|
// Verify they are correct.
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(pet sw.Pet) {
|
||||||
|
isPetCorrect(t, pet.Id, "gopherDan", "active")
|
||||||
|
errc <- nil
|
||||||
|
}(pet)
|
||||||
|
}
|
||||||
|
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
|
||||||
|
// Delete them all.
|
||||||
|
for _, pet := range newPets {
|
||||||
|
go func(id int64) {
|
||||||
|
deletePet(t, (int64)(id))
|
||||||
|
errc <- nil
|
||||||
|
}(pet.Id)
|
||||||
|
}
|
||||||
|
waitOnFunctions(t, errc, len(newPets))
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
func waitOnFunctions(t *testing.T, errc chan error, n int) {
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
err := <-errc
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error performing concurrent test: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func deletePet(t *testing.T, id int64) {
|
||||||
|
r, err := client.PetApi.DeletePet(context.Background(), id, nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while deleting pet by id: %v", err)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func isPetCorrect(t *testing.T, id int64, name string, status string) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
resp, r, err := client.PetApi.GetPetById(context.Background(), id)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error while getting pet by id: %v", err)
|
||||||
|
} else {
|
||||||
|
assert.Equal(resp.Id, int64(id), "Pet id should be equal")
|
||||||
|
assert.Equal(resp.Name, name, fmt.Sprintf("Pet name should be %s", name))
|
||||||
|
assert.Equal(resp.Status, status, fmt.Sprintf("Pet status should be %s", status))
|
||||||
|
|
||||||
|
//t.Log(resp)
|
||||||
|
}
|
||||||
|
if r.StatusCode != 200 {
|
||||||
|
t.Log(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
103
samples/openapi3/client/petstore/go/pom.xml
Normal file
103
samples/openapi3/client/petstore/go/pom.xml
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>GoOAS3Petstore</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<name>Go OpenAPI3 Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>go-get-testify</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>get</argument>
|
||||||
|
<argument>github.com/stretchr/testify/assert</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>go-get-oauth2</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>get</argument>
|
||||||
|
<argument>golang.org/x/oauth2</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>go-get-context</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>get</argument>
|
||||||
|
<argument>golang.org/x/net/context</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>go-get-optional</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>get</argument>
|
||||||
|
<argument>github.com/antihax/optional</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>go-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>go</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
<argument>-v</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user