Skip to content

Commit 4cb08ea

Browse files
committed
Add multipart/form-data example
1 parent d5eb00c commit 4cb08ea

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
openapi: 3.0.0
2+
info:
3+
version: 1.0.0
4+
title: Multipart form data
5+
6+
paths:
7+
"/api":
8+
post:
9+
responses:
10+
200:
11+
description: Response
12+
requestBody:
13+
$ref: "#/components/requestBodies/Multipart"
14+
"/noMaybes":
15+
post:
16+
responses:
17+
200:
18+
description: Response
19+
requestBody:
20+
$ref: "#/components/requestBodies/MultipartNoMaybes"
21+
components:
22+
requestBodies:
23+
Multipart:
24+
# https://swagger.io/docs/specification/v3_0/describing-request-body/multipart-requests/
25+
content:
26+
multipart/form-data: # Media type
27+
schema: # Request payload
28+
type: object
29+
required:
30+
- id
31+
properties: # Request parts
32+
id: # Part 1 (string value)
33+
type: string
34+
format: uuid
35+
address: # Part2 (object)
36+
type: object
37+
properties:
38+
street:
39+
type: string
40+
city:
41+
type: string
42+
profileImage: # Part 3 (an image)
43+
type: string
44+
format: binary
45+
MultipartNoMaybes:
46+
# https://swagger.io/docs/specification/v3_0/describing-request-body/multipart-requests/
47+
content:
48+
multipart/form-data: # Media type
49+
schema: # Request payload
50+
type: object
51+
required:
52+
- id
53+
- address
54+
- profileImage
55+
properties: # Request parts
56+
id: # Part 1 (string value)
57+
type: string
58+
format: uuid
59+
address: # Part2 (object)
60+
type: object
61+
properties:
62+
street:
63+
type: string
64+
city:
65+
type: string
66+
profileImage: # Part 3 (an image)
67+
type: string
68+
format: binary

‎cli/example/src/Example.elm‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import GithubV3RestApi.Api
1111
import GithubV3RestApi.Types
1212
import MarioPartyStats.Api
1313
import MarioPartyStats.Types
14+
import MultipartFormData.Api
1415
import NullableEnum.Json
1516
import OpenApi.Common
1617
import PatreonApi.Api
@@ -45,6 +46,9 @@ init () =
4546
let
4647
_ =
4748
SimpleRef.Json.decodeForbidden
49+
50+
_ =
51+
MultipartFormData.Api.api
4852
in
4953
( {}
5054
, Cmd.batch

‎cli/src/TestGenScript.elm‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ run =
5151
marioPartyStats =
5252
OpenApi.Config.inputFrom (OpenApi.Config.File "./example/MarioPartyStats.json")
5353

54+
multipartFormData : OpenApi.Config.Input
55+
multipartFormData =
56+
OpenApi.Config.inputFrom (OpenApi.Config.File "./example/multipart-form-data.yaml")
57+
5458
nullableEnum : OpenApi.Config.Input
5559
nullableEnum =
5660
OpenApi.Config.inputFrom (OpenApi.Config.File "./example/nullable-enum.yaml")
@@ -136,6 +140,7 @@ run =
136140
|> OpenApi.Config.withInput cookieAuth
137141
|> OpenApi.Config.withInput ifconfigOvh
138142
|> OpenApi.Config.withInput marioPartyStats
143+
|> OpenApi.Config.withInput multipartFormData
139144
|> OpenApi.Config.withInput nullableEnum
140145
|> OpenApi.Config.withInput overridingGlobalSecurity
141146
|> OpenApi.Config.withInput realworldConduit

0 commit comments

Comments
 (0)