Skip to content

Commit 6b8255c

Browse files
committed
Update Readme
1 parent c8b3058 commit 6b8255c

3 files changed

Lines changed: 38 additions & 34 deletions

File tree

README.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
<!-- --8<-- [start:docs] -->
12
# `oapi-codegen`
23

3-
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9450/badge)](https://www.bestpractices.dev/projects/9450)
4-
54
> **Battle-tested**: This generator is continuously tested against 2,000+ real-world OpenAPI specs, successfully generating and compiling over 20 million lines of Go code. Handles complex specs with circular references, deep nesting, and union types.
65
76
Using `oapi-codegen` allows you to reduce the boilerplate required to create or integrate with
@@ -53,14 +52,43 @@ oapi-codegen https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/ex
5352
```
5453

5554
## Examples
56-
The [examples directory](examples) contains cases with useful examples how to use `oapi-codegen`.
55+
The [examples directory](https://github.com/doordash-oss/oapi-codegen-dd/tree/main/examples) contains useful examples of how to use `oapi-codegen`.
56+
57+
## Why v3?
58+
59+
This project is a fork of [oapi-codegen](https://github.com/oapi-codegen/oapi-codegen) v2, fully reworked to address limitations in the original.
60+
61+
### Compatibility
62+
63+
Tested against [2,137 real-world OpenAPI 3.0 specs](https://github.com/cubahno/specs):
64+
65+
| Version | Passed | Failed | Pass Rate |
66+
|---------|--------|--------|-----------|
67+
| **v3** | 2,137 | 0 | **100%** |
68+
| v2 | 1,159 | 978 | 54.2% |
69+
70+
### Key Improvements
71+
72+
| Category | v2 | v3 |
73+
|----------|----|----|
74+
| **OpenAPI Support** | 3.0 only | 3.0, 3.1, 3.2 |
75+
| **Parser** | `kin-openapi` | `libopenapi` |
76+
| **Circular References** | Limited | Full support |
77+
| **Union Types (oneOf/anyOf)** | Basic | Full with optimizations |
78+
| **Name Conflicts** | Manual fix required | Automatic resolution |
79+
| **Validation** | None | `Validate()` methods |
80+
| **Server Scaffold** | Interface only, manual boilerplate | Full typed solution (service, middleware, main.go) |
81+
| **Filtering** | Tags, operation IDs | + Paths, extensions, schema properties |
82+
| **Overlays** | Single | Multiple, applied in order |
83+
| **Output** | Single file | Single or multiple files |
84+
| **Templates** | Monolithic | Composable with `{{define}}` blocks |
85+
| **Programmatic API** | Limited | Full (`ParseContext`, `TypeTracker`) |
86+
| **Server Frameworks** | 7 (Chi, Echo, Fiber, Gin, Gorilla, Iris, std-http) | 13 (+ Beego, go-zero, Kratos, GoFrame, Hertz, fasthttp) |
5787

88+
### Migration
5889

59-
## Migrate from v2
60-
This project is a fork of [oapi-codegen](https://github.com/oapi-codegen/oapi-codegen) v2.
61-
Due to the lack of OpenAPI 3.1 support in the original repository, we introduced a fully reworked implementation.
62-
While this includes some breaking changes, it also brings more flexible generator and parser APIs for finer control over code generation.
63-
If you're migrating from v2, please refer to the [migration guide](https://doordash-oss.github.io/oapi-codegen-dd/migrate-from-v2/) for important differences.
90+
If you're migrating from v2, please refer to the [migration guide](https://doordash-oss.github.io/oapi-codegen-dd/migrate-from-v2/).
91+
<!-- --8<-- [end:docs] -->
6492

6593
## License
6694
This project is licensed under the Apache License 2.0.

docs/index.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1 @@
1-
# oapi-codegen Documentation
2-
3-
Welcome to the oapi-codegen documentation! This tool helps you generate Go code from OpenAPI 3.x specifications, reducing boilerplate and letting you focus on your business logic.
4-
5-
6-
## Getting Started
7-
8-
```bash
9-
# Install
10-
go install github.com/doordash-oss/oapi-codegen-dd/v3/cmd/oapi-codegen@latest
11-
12-
# Generate code from the Petstore example
13-
oapi-codegen https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml > petstore.go
14-
```
15-
16-
## Best Practices
17-
18-
!!! tip "Define schemas in `#/components/schemas`"
19-
20-
Try to define as much as possible within the `#/components/schemas` object, as `oapi-codegen`
21-
will generate all the types here with clear, predictable names.
22-
23-
While we can generate types from inline definitions (e.g., in a path's response type),
24-
the generated type names may be less intuitive since they're derived from the path and operation.
25-
1+
--8<-- "README.md:docs"

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ markdown_extensions:
5252
- pymdownx.tabbed
5353
- pymdownx.details
5454
- pymdownx.snippets:
55-
base_path: ["examples"]
55+
base_path: [".", "examples"]
5656
- toc:
5757
permalink: true
5858

0 commit comments

Comments
 (0)