Skip to content

Commit cd519c4

Browse files
committed
Update documentation for XML coding
1 parent a14f44b commit cd519c4

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Sources/swift-openapi-generator/Documentation.docc/Articles/Supported-OpenAPI-features.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ For any other formats, the payload is provided as raw bytes (using the `HTTPBody
2424
- when content type is `application/x-www-form-urlencoded`
2525
- [x] multipart
2626
- for details, see [SOAR-0009](https://swiftpackageindex.com/apple/swift-openapi-generator/main/documentation/swift-openapi-generator/soar-0009)
27-
- [ ] XML
27+
- [X] XML
28+
- when content type is `application/xml` or ends with `+xml`
29+
- xmlCoder must be defined in `OpenAPIRuntime.Configuration`
2830

2931
### OpenAPI specification features
3032

Sources/swift-openapi-generator/Documentation.docc/Development/Converting-between-data-and-Swift-types.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ At the time of writing, the list of coders used is as follows.
2626
| Format | Encoder | Decoder | Supported in |
2727
| ------ | ------- | ------- | ----- |
2828
| JSON | `Foundation.JSONEncoder` | `Foundation.JSONDecoder` | Bodies, headers |
29-
| URI (†) | `OpenAPIRuntime.URIEncoder` | `OpenAPIRuntime.URIDecoder` | Path, query, headers |
29+
| XML (†) | `OpenAPIRuntime.CustomCoder` | `OpenAPIRuntime.CustomCoder` | Bodies |
30+
| URI (††) | `OpenAPIRuntime.URIEncoder` | `OpenAPIRuntime.URIDecoder` | Path, query, headers |
3031
| Plain text | `OpenAPIRuntime.StringEncoder` | `OpenAPIRuntime.StringDecoder` | Bodies |
3132

32-
> †: Configurable implementation of variable expansion from URI Template (RFC 6570), the `application/x-www-form-urlencoded` serialization from RFC 1866, and OpenAPI 3.0.3. For details of the supported combinations, review <doc:Supported-OpenAPI-features>.
33+
> †: XML support is optional, and not enabled by default. Encoding and decoding requires to define a `OpenAPIRuntime.CustomCoder` in `OpenAPIRuntime.Configuration` initializer.
34+
35+
> ††: Configurable implementation of variable expansion from URI Template (RFC 6570), the `application/x-www-form-urlencoded` serialization from RFC 1866, and OpenAPI 3.0.3. For details of the supported combinations, review <doc:Supported-OpenAPI-features>.
3336
3437
While the generator attempts to catch invalid inputs at generation time, there are still combinations of `Codable` types and locations that aren't compatible, and will only get caught at runtime by the specific coder implementation. For example, one could ask the `StringEncoder` to encode an array, but the encoder will throw an error, as containers are not supported in that encoder.
3538

@@ -50,6 +53,9 @@ Below is a list of the "dimensions" across which the helper methods differ:
5053
- `JSON`
5154
- example content type: `application/json` and any with the `+json` suffix
5255
- `{"color": "red", "power": 24}`
56+
- `XML`
57+
- example content type: `application/xml` and any with the `+xml` suffix
58+
- `<root><color>red</color><power>24</power></root>`
5359
- `URI`
5460
- example: query, path, header parameters
5561
- `color=red&power=24`
@@ -93,24 +99,30 @@ method parameters: value or type of value
9399
| client | set | request query | URI | both | setQueryItemAsURI |
94100
| client | set | request body | JSON | optional | setOptionalRequestBodyAsJSON |
95101
| client | set | request body | JSON | required | setRequiredRequestBodyAsJSON |
102+
| client | set | request body | XML | optional | setOptionalRequestBodyAsXML |
103+
| client | set | request body | XML | required | setRequiredRequestBodyAsXML |
96104
| client | set | request body | binary | optional | setOptionalRequestBodyAsBinary |
97105
| client | set | request body | binary | required | setRequiredRequestBodyAsBinary |
98106
| client | set | request body | urlEncodedForm | optional | setOptionalRequestBodyAsURLEncodedForm |
99107
| client | set | request body | urlEncodedForm | required | setRequiredRequestBodyAsURLEncodedForm |
100108
| client | set | request body | multipart | required | setRequiredRequestBodyAsMultipart |
101109
| client | get | response body | JSON | required | getResponseBodyAsJSON |
110+
| client | get | response body | XML | required | getResponseBodyAsXML |
102111
| client | get | response body | binary | required | getResponseBodyAsBinary |
103112
| client | get | response body | multipart | required | getResponseBodyAsMultipart |
104113
| server | get | request path | URI | required | getPathParameterAsURI |
105114
| server | get | request query | URI | optional | getOptionalQueryItemAsURI |
106115
| server | get | request query | URI | required | getRequiredQueryItemAsURI |
107116
| server | get | request body | JSON | optional | getOptionalRequestBodyAsJSON |
108117
| server | get | request body | JSON | required | getRequiredRequestBodyAsJSON |
118+
| server | get | request body | XML | optional | getOptionalRequestBodyAsXML |
119+
| server | get | request body | XML | required | getRequiredRequestBodyAsXML |
109120
| server | get | request body | binary | optional | getOptionalRequestBodyAsBinary |
110121
| server | get | request body | binary | required | getRequiredRequestBodyAsBinary |
111122
| server | get | request body | urlEncodedForm | optional | getOptionalRequestBodyAsURLEncodedForm |
112123
| server | get | request body | urlEncodedForm | required | getRequiredRequestBodyAsURLEncodedForm |
113124
| server | get | request body | multipart | required | getRequiredRequestBodyAsMultipart |
114125
| server | set | response body | JSON | required | setResponseBodyAsJSON |
126+
| server | set | response body | XML | required | setResponseBodyAsXML |
115127
| server | set | response body | binary | required | setResponseBodyAsBinary |
116128
| server | set | response body | multipart | required | setResponseBodyAsMultipart |

0 commit comments

Comments
 (0)