Skip to content

Commit 3d2422b

Browse files
committed
add default array spec and its generated result
Signed-off-by: titaneric <chenyihuang001@gmail.com>
1 parent 17842bc commit 3d2422b

19 files changed

Lines changed: 1872 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
generatorName: go
2+
outputDir: samples/client/others/go/array-default-value
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/go/spec-with-array-default-value.yaml
4+
additionalProperties:
5+
hideGenerationTimestamp: "true"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Minimal Array Default
4+
version: 1.0.0
5+
paths:
6+
/v1/configs:
7+
get:
8+
summary: List all configs
9+
description: List all configs
10+
operationId: listConfigs
11+
parameters:
12+
- $ref: '#/components/parameters/ConfigMapSort'
13+
responses:
14+
'200':
15+
description: OK
16+
content:
17+
application/json:
18+
schema:
19+
type: object
20+
components:
21+
parameters:
22+
ConfigMapSort:
23+
name: sort
24+
in: query
25+
required: false
26+
schema:
27+
type: array
28+
items:
29+
type: string
30+
default:
31+
- updatedAt
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Compiled Object files, Static and Dynamic libs (Shared Objects)
2+
*.o
3+
*.a
4+
*.so
5+
6+
# Folders
7+
_obj
8+
_test
9+
10+
# Architecture specific extensions/prefixes
11+
*.[568vq]
12+
[568vq].out
13+
14+
*.cgo1.go
15+
*.cgo2.c
16+
_cgo_defun.c
17+
_cgo_gotypes.go
18+
_cgo_export.*
19+
20+
_testmain.go
21+
22+
*.exe
23+
*.test
24+
*.prof
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.gitignore
2+
.travis.yml
3+
README.md
4+
api/openapi.yaml
5+
api_default.go
6+
client.go
7+
configuration.go
8+
docs/DefaultAPI.md
9+
git_push.sh
10+
go.mod
11+
go.sum
12+
response.go
13+
utils.go
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.19.0-SNAPSHOT
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: go
2+
3+
install:
4+
- go get -d -v .
5+
6+
script:
7+
- go build -v ./
8+
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Go API client for openapi
2+
3+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4+
5+
## Overview
6+
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
7+
8+
- API version: 1.0.0
9+
- Package version: 1.0.0
10+
- Generator version: 7.19.0-SNAPSHOT
11+
- Build package: org.openapitools.codegen.languages.GoClientCodegen
12+
13+
## Installation
14+
15+
Install the following dependencies:
16+
17+
```sh
18+
go get github.com/stretchr/testify/assert
19+
go get golang.org/x/net/context
20+
```
21+
22+
Put the package under your project folder and add the following in import:
23+
24+
```go
25+
import openapi "github.com/GIT_USER_ID/GIT_REPO_ID"
26+
```
27+
28+
To use a proxy, set the environment variable `HTTP_PROXY`:
29+
30+
```go
31+
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
32+
```
33+
34+
## Configuration of Server URL
35+
36+
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
37+
38+
### Select Server Configuration
39+
40+
For using other server than the one defined on index 0 set context value `openapi.ContextServerIndex` of type `int`.
41+
42+
```go
43+
ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)
44+
```
45+
46+
### Templated Server URL
47+
48+
Templated server URL is formatted using default variables from configuration or from context value `openapi.ContextServerVariables` of type `map[string]string`.
49+
50+
```go
51+
ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
52+
"basePath": "v2",
53+
})
54+
```
55+
56+
Note, enum values are always validated and all unused variables are silently ignored.
57+
58+
### URLs Configuration per Operation
59+
60+
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
61+
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
62+
Similar rules for overriding default operation server index and variables applies by using `openapi.ContextOperationServerIndices` and `openapi.ContextOperationServerVariables` context maps.
63+
64+
```go
65+
ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
66+
"{classname}Service.{nickname}": 2,
67+
})
68+
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
69+
"{classname}Service.{nickname}": {
70+
"port": "8443",
71+
},
72+
})
73+
```
74+
75+
## Documentation for API Endpoints
76+
77+
All URIs are relative to *http://localhost*
78+
79+
Class | Method | HTTP request | Description
80+
------------ | ------------- | ------------- | -------------
81+
*DefaultAPI* | [**ListConfigs**](docs/DefaultAPI.md#listconfigs) | **Get** /v1/configs | List all configs
82+
83+
84+
## Documentation For Models
85+
86+
87+
88+
## Documentation For Authorization
89+
90+
Endpoints do not require authorization.
91+
92+
93+
## Documentation for Utility Methods
94+
95+
Due to the fact that model structure members are all pointers, this package contains
96+
a number of utility functions to easily obtain pointers to values of basic types.
97+
Each of these functions takes a value of the given basic type and returns a pointer to it:
98+
99+
* `PtrBool`
100+
* `PtrInt`
101+
* `PtrInt32`
102+
* `PtrInt64`
103+
* `PtrFloat`
104+
* `PtrFloat32`
105+
* `PtrFloat64`
106+
* `PtrString`
107+
* `PtrTime`
108+
109+
## Author
110+
111+
112+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Minimal Array Default
4+
version: 1.0.0
5+
servers:
6+
- url: /
7+
paths:
8+
/v1/configs:
9+
get:
10+
description: List all configs
11+
operationId: listConfigs
12+
parameters:
13+
- explode: true
14+
in: query
15+
name: sort
16+
required: false
17+
schema:
18+
default:
19+
- updatedAt
20+
items:
21+
type: string
22+
type: array
23+
style: form
24+
responses:
25+
"200":
26+
content:
27+
application/json:
28+
schema:
29+
type: object
30+
description: OK
31+
summary: List all configs
32+
components:
33+
parameters:
34+
ConfigMapSort:
35+
explode: true
36+
in: query
37+
name: sort
38+
required: false
39+
schema:
40+
default:
41+
- updatedAt
42+
items:
43+
type: string
44+
type: array
45+
style: form
46+
schemas: {}

0 commit comments

Comments
 (0)