Skip to content

Commit 6bb3d63

Browse files
committed
add implicit free-form object example
1 parent b14a79e commit 6bb3d63

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

modules/openapi-generator/src/test/resources/3_0/elixir/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,23 @@ paths:
10121012
$ref: "#/components/schemas/FreeFormObject"
10131013
description: request body
10141014
required: true
1015+
/fake/implicitFreeFormObject:
1016+
post:
1017+
tags:
1018+
- fake
1019+
summary: test free form object with implicit additionalProperties
1020+
description: ""
1021+
operationId: testImplicitFreeFormObject
1022+
responses:
1023+
"200":
1024+
description: successful operation
1025+
requestBody:
1026+
content:
1027+
application/json:
1028+
schema:
1029+
$ref: "#/components/schemas/ImplicitFreeFormObject"
1030+
description: request body
1031+
required: true
10151032
/fake/stringMap-reference:
10161033
post:
10171034
tags:
@@ -1859,6 +1876,18 @@ components:
18591876
type: object
18601877
description: A schema consisting only of additional properties
18611878
additionalProperties: true
1879+
ImplicitFreeFormObject:
1880+
type: object
1881+
description: A schema consisting only of additional properties (implicit)
1882+
# AnyTypeObject:
1883+
# oneOf:
1884+
# - type: string
1885+
# - type: number
1886+
# - type: integer
1887+
# - type: boolean
1888+
# - type: object
1889+
# - type: array
1890+
# nullable: true
18621891
MapOfString:
18631892
type: object
18641893
description: A schema consisting only of additional properties of type string

samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,37 @@ defmodule OpenapiPetstore.Api.Fake do
585585
])
586586
end
587587

588+
@doc """
589+
test free form object with implicit additionalProperties
590+
591+
592+
### Parameters
593+
594+
- `connection` (OpenapiPetstore.Connection): Connection to server
595+
- `body` (%{optional(String.t) => any()}): request body
596+
- `opts` (keyword): Optional parameters
597+
598+
### Returns
599+
600+
- `{:ok, nil}` on success
601+
- `{:error, Tesla.Env.t}` on failure
602+
"""
603+
@spec test_implicit_free_form_object(Tesla.Env.client, %{optional(String.t) => any()}, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
604+
def test_implicit_free_form_object(connection, body, _opts \\ []) do
605+
request =
606+
%{}
607+
|> method(:post)
608+
|> url("/fake/implicitFreeFormObject")
609+
|> add_param(:body, :body, body)
610+
|> Enum.into([])
611+
612+
connection
613+
|> Connection.request(request)
614+
|> evaluate_response([
615+
{200, false}
616+
])
617+
end
618+
588619
@doc """
589620
test inline additionalProperties
590621

0 commit comments

Comments
 (0)