Skip to content

Commit 6433ac6

Browse files
committed
generate with openapi-generator
1 parent e084d0c commit 6433ac6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+235604
-240918
lines changed

kubernetes/.swagger-codegen-ignore renamed to kubernetes/.openapi-generator-ignore

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Swagger Codegen Ignore
2-
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
33

44
# Use this file to prevent files from being overwritten by the generator.
55
# The patterns follow closely to .gitignore or .dockerignore.
66

77
# As an example, the C# client generator defines ApiClient.cs.
8-
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
99
#ApiClient.cs
1010

1111
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
@@ -21,5 +21,3 @@
2121
#docs/*.md
2222
# Then explicitly reverse the ignore rule for a single file:
2323
#!docs/README.md
24-
25-
README.md

kubernetes/.openapi-generator/COMMIT

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Requested Commit: c30a21ac3cd8b1d8a3db600e4079977af0681e11
2+
Actual Commit: c30a21ac3cd8b1d8a3db600e4079977af0681e11

kubernetes/.openapi-generator/VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0.0-SNAPSHOT
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
68a75356636abec984972b3864294695fe7f117192ddd4acd5ffa77a215422e4

kubernetes/.swagger-codegen/COMMIT

-2
This file was deleted.

kubernetes/.swagger-codegen/VERSION

-1
This file was deleted.

kubernetes/README.md

+195-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,200 @@
1-
## Swagger Auto-Generated [http-client](https://www.stackage.org/lts-9.0/package/http-client-0.5.7.0) Bindings to `Kubernetes`
1+
## OpenAPI Auto-Generated [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) Bindings to `Kubernetes`
22

3-
The library in `lib` provides auto-generated-from-Swagger [http-client](https://www.stackage.org/lts-9.0/package/http-client-0.5.7.0) bindings to the Kubernetes API.
3+
The library in `lib` provides auto-generated-from-OpenAPI [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) bindings to the Kubernetes API.
44

5-
Targeted swagger version: 2.0
5+
OpenApi Version: 3.0.1
66

7-
OpenAPI-Specification: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
7+
## Installation
88

9-
## Usage
9+
Installation follows the standard approach to installing Stack-based projects.
1010

11-
Please refer to the README of the `kubernetes-client-helper` package.
11+
1. Install the [Haskell `stack` tool](http://docs.haskellstack.org/en/stable/README).
12+
2. To build the package, and generate the documentation (recommended):
13+
```
14+
stack haddock
15+
```
16+
which will generate docs for this lib in the `docs` folder.
17+
18+
To generate the docs in the normal location (to enable hyperlinks to external libs), remove
19+
```
20+
build:
21+
haddock-arguments:
22+
haddock-args:
23+
- "--odir=./docs"
24+
```
25+
from the stack.yaml file and run `stack haddock` again.
26+
27+
3. To run unit tests:
28+
```
29+
stack test
30+
```
31+
32+
## OpenAPI-Generator
33+
34+
The code generator that produced this library, and which explains how
35+
to obtain and use the openapi-generator cli tool lives at
36+
37+
https://openapi-generator.tech
38+
39+
The _generator-name_ argument (`--generator-name`) passed to the cli tool used should be
40+
41+
```
42+
haskell-http-client
43+
```
44+
45+
### Unsupported OpenAPI Features
46+
47+
* Model Inheritance
48+
49+
This is beta software; other cases may not be supported.
50+
51+
### Codegen "additional properties" parameters
52+
53+
These options allow some customization of the code generation process.
54+
55+
**haskell-http-client additional properties:**
56+
57+
| OPTION | DESCRIPTION | DEFAULT | ACTUAL |
58+
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------- |
59+
| allowFromJsonNulls | allow JSON Null during model decoding from JSON | true | true |
60+
| allowNonUniqueOperationIds | allow *different* API modules to contain the same operationId. Each API must be imported qualified | false | true |
61+
| allowToJsonNulls | allow emitting JSON Null during model encoding to JSON | false | false |
62+
| baseModule | Set the base module namespace | | Kubernetes.OpenAPI |
63+
| cabalPackage | Set the cabal package name, which consists of one or more alphanumeric words separated by hyphens | | kubernetes-openapi-client-gen |
64+
| cabalVersion | Set the cabal version number, consisting of a sequence of one or more integers separated by dots | 0.1.0.0 | 0.1.0.0 |
65+
| configType | Set the name of the type used for configuration | | KubernetesClientConfig |
66+
| dateFormat | format string used to parse/render a date | %Y-%m-%d | %Y-%m-%d |
67+
| dateTimeFormat | format string used to parse/render a datetime. (Defaults to [formatISO8601Millis][1] when not provided) | | |
68+
| generateEnums | Generate specific datatypes for OpenAPI enums | true | true |
69+
| generateFormUrlEncodedInstances | Generate FromForm/ToForm instances for models used by x-www-form-urlencoded operations (model fields must be primitive types) | true | true |
70+
| generateLenses | Generate Lens optics for Models | true | true |
71+
| generateModelConstructors | Generate smart constructors (only supply required fields) for models | true | true |
72+
| inlineMimeTypes | Inline (hardcode) the content-type and accept parameters on operations, when there is only 1 option | true | true |
73+
| modelDeriving | Additional classes to include in the deriving() clause of Models | | |
74+
| requestType | Set the name of the type used to generate requests | | KubernetesRequest |
75+
| strictFields | Add strictness annotations to all model fields | true | true |
76+
| useKatip | Sets the default value for the UseKatip cabal flag. If true, the katip package provides logging instead of monad-logger | true | true |
77+
78+
[1]: https://www.stackage.org/haddock/lts-9.0/iso8601-time-0.1.4/Data-Time-ISO8601.html#v:formatISO8601Millis
79+
80+
An example setting _strictFields_ and _dateTimeFormat_:
81+
82+
```
83+
java -jar openapi-generator-cli.jar generate -i petstore.yaml -g haskell-http-client -o output/haskell-http-client -DstrictFields=true -DdateTimeFormat="%Y-%m-%dT%H:%M:%S%Q%z"
84+
```
85+
86+
View the full list of Codegen "config option" parameters with the command:
87+
88+
```
89+
java -jar openapi-generator-cli.jar config-help -g haskell-http-client
90+
```
91+
92+
## Usage Notes
93+
94+
### Example Petstore Haddock documentation
95+
96+
An example of the generated haddock documentation targeting the server http://petstore.swagger.io/ (Petstore) can be found [here][2]
97+
98+
[2]: https://hackage.haskell.org/package/swagger-petstore
99+
100+
### Example Petstore App
101+
102+
An example application using the auto-generated haskell-http-client bindings for the server http://petstore.swagger.io/ can be found [here][3]
103+
104+
[3]: https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/haskell-http-client/example-app
105+
106+
This library is intended to be imported qualified.
107+
108+
### Modules
109+
110+
| MODULE | NOTES |
111+
| ------------------- | --------------------------------------------------- |
112+
| Kubernetes.OpenAPI.Client | use the "dispatch" functions to send requests |
113+
| Kubernetes.OpenAPI.Core | core funcions, config and request types |
114+
| Kubernetes.OpenAPI.API | construct api requests |
115+
| Kubernetes.OpenAPI.Model | describes api models |
116+
| Kubernetes.OpenAPI.MimeTypes | encoding/decoding MIME types (content-types/accept) |
117+
| Kubernetes.OpenAPI.ModelLens | lenses for model fields |
118+
| Kubernetes.OpenAPI.Logging | logging functions and utils |
119+
120+
121+
### MimeTypes
122+
123+
This library adds type safety around what OpenAPI specifies as
124+
Produces and Consumes for each Operation (e.g. the list of MIME types an
125+
Operation can Produce (using 'accept' headers) and Consume (using 'content-type' headers).
126+
127+
For example, if there is an Operation named _addFoo_, there will be a
128+
data type generated named _AddFoo_ (note the capitalization), which
129+
describes additional constraints and actions on the _addFoo_ operation
130+
via its typeclass instances. These typeclass instances can be viewed
131+
in GHCi or via the Haddocks.
132+
133+
* required parameters are included as function arguments to _addFoo_
134+
* optional non-body parameters are included by using `applyOptionalParam`
135+
* optional body parameters are set by using `setBodyParam`
136+
137+
Example code generated for pretend _addFoo_ operation:
138+
139+
```haskell
140+
data AddFoo
141+
instance Consumes AddFoo MimeJSON
142+
instance Produces AddFoo MimeJSON
143+
instance Produces AddFoo MimeXML
144+
instance HasBodyParam AddFoo FooModel
145+
instance HasOptionalParam AddFoo FooName
146+
instance HasOptionalParam AddFoo FooId
147+
```
148+
149+
this would indicate that:
150+
151+
* the _addFoo_ operation can consume JSON
152+
* the _addFoo_ operation produces JSON or XML, depending on the argument passed to the dispatch function
153+
* the _addFoo_ operation can set it's body param of _FooModel_ via `setBodyParam`
154+
* the _addFoo_ operation can set 2 different optional parameters via `applyOptionalParam`
155+
156+
If the OpenAPI spec doesn't declare it can accept or produce a certain
157+
MIME type for a given Operation, you should either add a Produces or
158+
Consumes instance for the desired MIME types (assuming the server
159+
supports it), use `dispatchLbsUnsafe` or modify the OpenAPI spec and
160+
run the generator again.
161+
162+
New MIME type instances can be added via MimeType/MimeRender/MimeUnrender
163+
164+
Only JSON instances are generated by default, and in some case
165+
x-www-form-urlencoded instances (FromFrom, ToForm) will also be
166+
generated if the model fields are primitive types, and there are
167+
Operations using x-www-form-urlencoded which use those models.
168+
169+
### Authentication
170+
171+
A haskell data type will be generated for each OpenAPI authentication type.
172+
173+
If for example the AuthMethod `AuthOAuthFoo` is generated for OAuth operations, then
174+
`addAuthMethod` should be used to add the AuthMethod config.
175+
176+
When a request is dispatched, if a matching auth method is found in
177+
the config, it will be applied to the request.
178+
179+
### Example
180+
181+
```haskell
182+
mgr <- newManager defaultManagerSettings
183+
config0 <- withStdoutLogging =<< newConfig
184+
let config = config0
185+
`addAuthMethod` AuthOAuthFoo "secret-key"
186+
187+
let addFooRequest =
188+
addFoo
189+
(ContentType MimeJSON)
190+
(Accept MimeXML)
191+
(ParamBar paramBar)
192+
(ParamQux paramQux)
193+
modelBaz
194+
`applyOptionalParam` FooId 1
195+
`applyOptionalParam` FooName "name"
196+
`setHeader` [("qux_header","xxyy")]
197+
addFooResult <- dispatchMime mgr config addFooRequest
198+
```
199+
200+
See the example app and the haddocks for details.

kubernetes/git_push.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
33
#
4-
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
4+
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
55

66
git_user_id=$1
77
git_repo_id=$2

kubernetes/kubernetes-openapi-client-gen.cabal

+22-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ synopsis: Auto-generated kubernetes-openapi-client-gen API Client
44
description: .
55
Client library for calling the Kubernetes API based on http-client.
66
.
7-
host:
7+
host: localhost
88
.
9-
base path: https://localhost
9+
base path: http://localhost
1010
.
1111
Kubernetes API version: v1.9.12
1212
.
13-
OpenAPI spec version: 2.0
13+
OpenAPI version: 3.0.1
1414
.
15-
OpenAPI-Specification: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
16-
.
17-
category: Web
15+
category: Web
1816
homepage: https://github.com/kubernetes-client/haskell
1917
author: Auto Generated
2018
maintainer: Shimin Guo <[email protected]>
@@ -24,7 +22,12 @@ cabal-version: >= 1.10
2422

2523
extra-source-files:
2624
README.md
27-
swagger.yaml
25+
openapi.yaml
26+
27+
Flag UseKatip
28+
Description: Use the katip package to provide logging (if false, use the default monad-logger package)
29+
Default: True
30+
Manual: True
2831

2932
library
3033
hs-source-dirs:
@@ -36,26 +39,25 @@ library
3639
, base64-bytestring >1.0 && <2.0
3740
, bytestring >=0.10.0 && <0.11
3841
, case-insensitive
39-
, containers >=0.5.0.0 && <0.6
42+
, containers >=0.5.0.0 && <0.8
4043
, deepseq >= 1.4 && <1.6
4144
, exceptions >= 0.4
42-
, http-api-data >= 0.3.4 && <0.4
45+
, http-api-data >= 0.3.4 && <0.5
4346
, http-client >=0.5 && <0.6
4447
, http-client-tls
4548
, http-media >= 0.4 && < 0.8
4649
, http-types >=0.8 && <0.13
4750
, iso8601-time >=0.1.3 && <0.2.0
4851
, microlens >= 0.4.3 && <0.5
4952
, mtl >=2.2.1
50-
, network >=2.6.2 && <2.7
53+
, network >=2.6.2 && <2.9
5154
, random >=1.1
5255
, safe-exceptions <0.2
5356
, text >=0.11 && <1.3
5457
, time >=1.5 && <1.10
5558
, transformers >=0.4.0.0
5659
, unordered-containers
5760
, vector >=0.10.9 && <0.13
58-
, katip >=0.4 && < 0.6
5961
other-modules:
6062
Paths_kubernetes_openapi_client_gen
6163
exposed-modules:
@@ -120,6 +122,15 @@ library
120122
Kubernetes.OpenAPI.ModelLens
121123
default-language: Haskell2010
122124

125+
if flag(UseKatip)
126+
build-depends: katip >=0.6 && < 1.0
127+
other-modules: Kubernetes.OpenAPI.LoggingKatip
128+
cpp-options: -DUSE_KATIP
129+
else
130+
build-depends: monad-logger >=0.3 && <0.4
131+
other-modules: Kubernetes.OpenAPI.LoggingMonadLogger
132+
cpp-options: -DUSE_MONAD_LOGGER
133+
123134
test-suite tests
124135
type: exitcode-stdio-1.0
125136
main-is: Test.hs

kubernetes/lib/Kubernetes/OpenAPI.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{-
22
Kubernetes
33
4-
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
4+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
55
6-
OpenAPI spec version: 2.0
6+
OpenAPI Version: 3.0.1
77
Kubernetes API version: v1.9.12
8-
Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
8+
Generated by OpenAPI Generator (https://openapi-generator.tech)
99
-}
1010

1111
{-|

kubernetes/lib/Kubernetes/OpenAPI/API/Admissionregistration.hs

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{-
22
Kubernetes
33
4-
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
4+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
55
6-
OpenAPI spec version: 2.0
6+
OpenAPI Version: 3.0.1
77
Kubernetes API version: v1.9.12
8-
Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
8+
Generated by OpenAPI Generator (https://openapi-generator.tech)
99
-}
1010

1111
{-|
@@ -73,18 +73,10 @@ getAPIGroup _ =
7373
`_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyBearerToken)
7474

7575
data GetAPIGroup
76-
77-
-- | @application/json@
78-
instance Consumes GetAPIGroup MimeJSON
79-
-- | @application/yaml@
80-
instance Consumes GetAPIGroup MimeYaml
81-
-- | @application/vnd.kubernetes.protobuf@
82-
instance Consumes GetAPIGroup MimeVndKubernetesProtobuf
83-
8476
-- | @application/json@
8577
instance Produces GetAPIGroup MimeJSON
86-
-- | @application/yaml@
87-
instance Produces GetAPIGroup MimeYaml
8878
-- | @application/vnd.kubernetes.protobuf@
8979
instance Produces GetAPIGroup MimeVndKubernetesProtobuf
80+
-- | @application/yaml@
81+
instance Produces GetAPIGroup MimeYaml
9082

0 commit comments

Comments
 (0)