Skip to content

Commit 0aecf2a

Browse files
authored
feat: support application/x-www-form-urlencoded request bodies (#352)
adds support for `application/x-www-form-urlencoded` request bodies, including the `encoding` property to customize the serialization of object and array values. it's implemented for `typescript-fetch` and `typescript-axios` with partial support on the server templates (they don't currently understand encoding, so its a bit of pot-luck whether they'll accurately de-serialize the data) later we'll extract some of the duplicated code into a new core runtime package, as there's an increasingly large body of code that is shared between the different runtimes. additionally improves handling of optional request bodies, particularly in the case that the consuming project has `exactOptionalPropertyTypes` enabled. This is currently more correct on the `typescript-fetch` template, due to some quirks of `axios` - see skipped `e2e` tests for details.
1 parent 032e5c2 commit 0aecf2a

58 files changed

Lines changed: 182796 additions & 20735 deletions

File tree

Some content is hidden

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

e2e/openapi.yaml

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ paths:
5353
responses:
5454
200:
5555
$ref: '#/components/responses/GetHeaders'
56+
5657
/validation/numbers/random-number:
5758
get:
5859
tags:
@@ -101,24 +102,38 @@ paths:
101102
application/json:
102103
schema:
103104
$ref: '#/components/schemas/Enumerations'
105+
/validation/optional-body:
106+
post:
107+
tags:
108+
- validation
109+
requestBody:
110+
required: false
111+
content:
112+
application/json:
113+
schema:
114+
type: object
115+
properties:
116+
id:
117+
type: string
118+
responses:
119+
200:
120+
description: ok
121+
content:
122+
application/json:
123+
schema:
124+
type: object
125+
properties:
126+
id:
127+
type: string
128+
204:
129+
description: ok
104130
/responses/500:
105131
get:
106132
tags:
107133
- validation
108134
responses:
109135
500:
110136
description: Internal Server Error
111-
/escape-hatches/plain-text:
112-
get:
113-
tags:
114-
- escape hatches
115-
responses:
116-
200:
117-
description: 'ok'
118-
content:
119-
text/plain:
120-
schema:
121-
type: string
122137
/responses/empty:
123138
get:
124139
tags:
@@ -144,6 +159,39 @@ paths:
144159
text/html:
145160
schema:
146161
type: string
162+
/media-types/x-www-form-urlencoded:
163+
post:
164+
tags:
165+
- media types
166+
requestBody:
167+
content:
168+
application/x-www-form-urlencoded:
169+
schema:
170+
$ref: '#/components/schemas/ProductOrder'
171+
encoding:
172+
address:
173+
style: deepObject
174+
explode: true
175+
required: true
176+
responses:
177+
200:
178+
description: Echoed back as JSON
179+
content:
180+
application/json:
181+
schema:
182+
$ref: '#/components/schemas/ProductOrder'
183+
184+
/escape-hatches/plain-text:
185+
get:
186+
tags:
187+
- escape hatches
188+
responses:
189+
200:
190+
description: 'ok'
191+
content:
192+
text/plain:
193+
schema:
194+
type: string
147195

148196
components:
149197
responses:
@@ -194,3 +242,18 @@ components:
194242
type: array
195243
items:
196244
type: number
245+
ProductOrder:
246+
type: object
247+
properties:
248+
sku:
249+
type: string
250+
quantity:
251+
type: number
252+
minimum: 1
253+
address:
254+
type: object
255+
properties:
256+
address1:
257+
type: string
258+
postcode:
259+
type: string

e2e/src/generated/client/axios/client.ts

Lines changed: 86 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/src/generated/client/axios/models.ts

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/src/generated/client/axios/schemas.ts

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)