Skip to content

Commit 423defe

Browse files
author
Jamie Tanna
committed
sq
1 parent 457da08 commit 423defe

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed

README.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ release version.
1414

1515
## OpenAPI Client and Server Code Generator
1616

17+
```
1718
This package contains a set of utilities for generating Go boilerplate code for
1819
services based on
1920
[OpenAPI 3.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md)
@@ -38,6 +39,166 @@ typed Go code for all possible OpenAPI Schemas. If there is a way to accomplish
3839
something via utility code or reflection, it's probably a better approach than
3940
code generation, which is fragile due to the very dynamic nature of OpenAPI and
4041
the very static nature of Go.
42+
```
43+
44+
## Install
45+
46+
It is recommended to follow [the `tools.go` pattern](https://www.jvt.me/posts/2022/06/15/go-tools-dependency-management/) for managing the dependency of `oapi-codegen` alongside your core application.
47+
48+
This would give you a `tools/tools.go`:
49+
50+
```go
51+
//go:build tools
52+
// +build tools
53+
54+
package main
55+
56+
import (
57+
_ "github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen"
58+
)
59+
```
60+
61+
Then, each **??**
62+
63+
Alternatively, you can install it as a binary with:
64+
65+
```sh
66+
$ go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest
67+
$ oapi-codegen -version
68+
```
69+
70+
## Usage
71+
72+
`oapi-codegen` is largely **??**.
73+
74+
For full https://pkg.go.dev/github.com/deepmap/oapi-codegen/v2/pkg/codegen#Configuration
75+
76+
## Features
77+
78+
`oapi-codegen` supports:
79+
80+
- Generating server-side boilerplate for [a number of servers]
81+
- Generating client API boilerplate
82+
- Generating the types
83+
- Splitting **??**
84+
- Also described as ["external refs"] or "Import Mappings" in our documentation
85+
86+
## Key design decisions
87+
88+
- Bulk processing and parsing of OpenAPI document in Go
89+
- Resulting output is using Go's `text/template`s, which are user-overridable
90+
- Idiomatic Go
91+
- Single-file output
92+
- Support multiple OpenAPI files by having a package-per-file
93+
- **??**
94+
95+
### Generating server-side boilerplate
96+
97+
`oapi-codegen` shines by making it fairly straightforward (note that this is a purposeful choice of wording here - we want to avoid words like "easy") to generate the server-side boilerplate for a backend API.
98+
99+
```
100+
--------
101+
```
102+
103+
Now you've generated this, you need to implement **??**.
104+
105+
```go
106+
107+
```
108+
109+
To provide you a fully Test Driven Development style test harness, you could use a tool such as **??** to **??**.
110+
111+
#### Supported Servers
112+
113+
<table>
114+
115+
<tr>
116+
<th>
117+
Server name
118+
</th>
119+
<th>
120+
Configuration **??**
121+
</th>
122+
</tr>
123+
124+
<tr>
125+
<td>
126+
</td>
127+
<td>
128+
<code> </code>
129+
</td>
130+
</tr>
131+
132+
<tr>
133+
<td>
134+
</td>
135+
<td>
136+
<code> </code>
137+
</td>
138+
</tr>
139+
140+
<tr>
141+
<td>
142+
</td>
143+
<td>
144+
<code> </code>
145+
</td>
146+
</tr>
147+
148+
<tr>
149+
<td>
150+
</td>
151+
<td>
152+
<code> </code>
153+
</td>
154+
</tr>
155+
156+
</table>
157+
158+
### Generating API clients
159+
160+
### Generating API models
161+
162+
If you're looking to only generate the models for interacting with a remote service, for instance if you need to hand-roll the API client for whatever reason, you can do this as-is.
163+
164+
### Generating Nullable types
165+
166+
Opt-in, **??**
167+
168+
### OpenAPI extensions
169+
170+
As well as inbuilt OpenAPI, we also support the following OpenAPI extensions.
171+
172+
####
173+
174+
### Custom code generation
175+
176+
It is possible to extend **??** using the templates **??**.
177+
178+
Alternatively, you are able to use the underlying code generation as a package, which [will be documented in the future](https://github.com/deepmap/oapi-codegen/issues/1487).
179+
180+
## Examples
181+
182+
The [examples directory] contains some **??**, including how you'd take the Petstore API and **??**.
183+
184+
185+
186+
### Blog posts
187+
188+
The are a number of **??**
189+
190+
- TODO
191+
https://www.jvt.me/posts/2022/07/12/go-openapi-server/
192+
193+
Got one to add? Please raise a PR!
194+
195+
--------
196+
--------
197+
--------
198+
--------
199+
--------
200+
--------
201+
--------
41202

42203
## Overview
43204

0 commit comments

Comments
 (0)