diff --git a/cli/example/multipart-form-data.yaml b/cli/example/multipart-form-data.yaml new file mode 100644 index 00000000..2a8af853 --- /dev/null +++ b/cli/example/multipart-form-data.yaml @@ -0,0 +1,68 @@ +openapi: 3.0.0 +info: + version: 1.0.0 + title: Multipart form data + +paths: + "/api": + post: + responses: + 200: + description: Response + requestBody: + $ref: "#/components/requestBodies/Multipart" + "/noMaybes": + post: + responses: + 200: + description: Response + requestBody: + $ref: "#/components/requestBodies/MultipartNoMaybes" +components: + requestBodies: + Multipart: + # https://swagger.io/docs/specification/v3_0/describing-request-body/multipart-requests/ + content: + multipart/form-data: # Media type + schema: # Request payload + type: object + required: + - id + properties: # Request parts + id: # Part 1 (string value) + type: string + format: uuid + address: # Part2 (object) + type: object + properties: + street: + type: string + city: + type: string + profileImage: # Part 3 (an image) + type: string + format: binary + MultipartNoMaybes: + # https://swagger.io/docs/specification/v3_0/describing-request-body/multipart-requests/ + content: + multipart/form-data: # Media type + schema: # Request payload + type: object + required: + - id + - address + - profileImage + properties: # Request parts + id: # Part 1 (string value) + type: string + format: uuid + address: # Part2 (object) + type: object + properties: + street: + type: string + city: + type: string + profileImage: # Part 3 (an image) + type: string + format: binary diff --git a/cli/example/src/Example.elm b/cli/example/src/Example.elm index b0218761..70e7ef9d 100644 --- a/cli/example/src/Example.elm +++ b/cli/example/src/Example.elm @@ -11,6 +11,7 @@ import GithubV3RestApi.Api import GithubV3RestApi.Types import MarioPartyStats.Api import MarioPartyStats.Types +import MultipartFormData.Api import NullableEnum.Json import OpenApi.Common import PatreonApi.Api @@ -45,6 +46,9 @@ init () = let _ = SimpleRef.Json.decodeForbidden + + _ = + MultipartFormData.Api.api in ( {} , Cmd.batch diff --git a/cli/src/TestGenScript.elm b/cli/src/TestGenScript.elm index 51d594ce..2c3e70b1 100644 --- a/cli/src/TestGenScript.elm +++ b/cli/src/TestGenScript.elm @@ -51,6 +51,10 @@ run = marioPartyStats = OpenApi.Config.inputFrom (OpenApi.Config.File "./example/MarioPartyStats.json") + multipartFormData : OpenApi.Config.Input + multipartFormData = + OpenApi.Config.inputFrom (OpenApi.Config.File "./example/multipart-form-data.yaml") + nullableEnum : OpenApi.Config.Input nullableEnum = OpenApi.Config.inputFrom (OpenApi.Config.File "./example/nullable-enum.yaml") @@ -136,6 +140,7 @@ run = |> OpenApi.Config.withInput cookieAuth |> OpenApi.Config.withInput ifconfigOvh |> OpenApi.Config.withInput marioPartyStats + |> OpenApi.Config.withInput multipartFormData |> OpenApi.Config.withInput nullableEnum |> OpenApi.Config.withInput overridingGlobalSecurity |> OpenApi.Config.withInput realworldConduit