|
1 | 1 | # `oapi-codegen` |
2 | 2 |
|
3 | | -`oapi-codegen` is a command-line tool and library, to convert OpenAPI API specifications to Go code, be it server-side implementations, API clients, or simply HTTP models. |
| 3 | +`oapi-codegen` is a command-line tool and library to convert OpenAPI specifications to Go code, be it server-side implementations, API clients, or simply HTTP models. |
4 | 4 |
|
5 | 5 | `oapi-codegen` aims to reduce some of the tedious boilerplate that can be found when building or interacting with APIs, and focusses on: |
6 | 6 |
|
@@ -50,18 +50,18 @@ Which then means you can invoke it like so: |
50 | 50 |
|
51 | 51 | ## Usage |
52 | 52 |
|
53 | | -`oapi-codegen` is largely configured using a YAML configuration file, to simplify the number of flags that users need to remember. |
| 53 | +`oapi-codegen` is largely configured using a YAML configuration file, to simplify the number of flags that users need to remember, and to tune various **??**. |
54 | 54 |
|
55 | | -For full https://pkg.go.dev/github.com/deepmap/oapi-codegen/v2/pkg/codegen#Configuration |
| 55 | +For full details of what is supported, it's worth checking out [the GoDoc for `codegen.Configuration`](https://pkg.go.dev/github.com/deepmap/oapi-codegen/v2/pkg/codegen#Configuration). |
56 | 56 |
|
57 | 57 | ## Features |
58 | 58 |
|
59 | 59 | `oapi-codegen` supports: |
60 | 60 |
|
61 | | -- Generating server-side boilerplate for [a number of servers] TODO |
62 | | -- Generating client API boilerplate |
63 | | -- Generating the types |
64 | | -- Splitting **??** |
| 61 | +- Generating server-side boilerplate for [a number of servers] TODO ([docs](#generating-server-side-boilerplate)) |
| 62 | +- Generating client API boilerplate ([docs](#generating-api-clients)) |
| 63 | +- Generating the types ([docs](#generating-api-models)) |
| 64 | +- Splitting **??** ([docs](#import-mapping)) |
65 | 65 | - Also described as ["external refs"] or "Import Mappings" in our documentation |
66 | 66 |
|
67 | 67 | ## Key design decisions |
@@ -458,7 +458,7 @@ This **??** |
458 | 458 | --------------------- TODO --------- |
459 | 459 | ``` |
460 | 460 |
|
461 | | -oapi-codegen also supports generating RPC inspired strict server, that will parse request bodies and encode responses. |
| 461 | +`oapi-codegen` also supports generating RPC inspired strict server, that will parse request bodies and encode responses. |
462 | 462 | The main points of this code is to automate some parsing, abstract user code from server specific code, |
463 | 463 | and also to force user code to comply with the schema. |
464 | 464 | It supports binding of `application/json` and `application/x-www-form-urlencoded` to a struct, for `multipart` requests |
@@ -795,6 +795,13 @@ output-options: |
795 | 795 |
|
796 | 796 | For a complete example see [`examples/petstore-expanded/only-models`](examples/petstore-expanded/only-models). |
797 | 797 |
|
| 798 | +### Splitting large OpenAPI specs across multiple packages (aka "Import Mapping" or "external references") |
| 799 | +<a name=import-mapping></a> |
| 800 | + |
| 801 | +``` |
| 802 | +TODO |
| 803 | +``` |
| 804 | +
|
798 | 805 | ### Generating Nullable types |
799 | 806 |
|
800 | 807 | It's possible that you want to be able to determine whether a field isn't sent, is sent as `null` or has a value. |
|
811 | 818 | required: [] |
812 | 819 | ``` |
813 | 820 |
|
814 | | -The default behaviour in oapi-codegen is to generate: |
| 821 | +The default behaviour in `oapi-codegen` is to generate: |
815 | 822 |
|
816 | 823 | ```go |
817 | 824 | type S struct { |
@@ -887,8 +894,6 @@ For simplicity, and to remove a fair bit of duplication and boilerplate, `oapi-c |
887 | 894 |
|
888 | 895 | Below you can see some examples of how `additionalProperties` affects the generated code. |
889 | 896 |
|
890 | | -There are many special cases for `additionalProperties`, such as having to define types for inner fields which themselves support `additionalProperties`, and all of them are tested via the [`internal/test/components`](internal/test/components) schemas and tests. Please look through those tests for more usage examples. |
891 | | - |
892 | 897 | #### Implicit `additionalProperties: true` / no `additionalProperties` set |
893 | 898 |
|
894 | 899 | ```yaml |
|
0 commit comments