Closed paulbalomiri closed 5 months ago
Actually it could also be OApi.Kratos.Identity.JsonPatchDocument.t()
, but i think arrays are not mapped by name.
So in this case perhaps a @type json_patch_document:: [json_patch]
would help?
The description could then be put into @typedoc
Hi there 👋🏼
I'm having some trouble replicating the issue; would you mind posting or linking the full example spec (something I can copy right in and generate to see the issue)?
Thanks! ❤️
something I can copy right in and generate to see the issue
still having some falloff from the last deployment. Is it a blocker for you if we postpone this for two weeks ? If yes i'll sqeeze it in tomorrow.
In any case let me give you some more context here by providing more of the the generated code, now, before i open source the whole library & client implementation.
Right now it's in our monorepo, so ejecting it from there needs a day of work (for all libs kratos, hydra & client).
So here is the full generated function. The problem exists only in the @type
spec!.
jsonPatchDocument
is an array type of jsonPatch
:
@doc """
Patch an Identity
Partially updates an [identity's](https://www.ory.sh/docs/kratos/concepts/identity-user-model) field using [JSON Patch](https://jsonpatch.com/).
The fields `id`, `stateChangedAt` and `credentials` can not be updated using this method.
"""
# v This is wrong according to spec
@spec patch_identity(String.t(), OApi.Kratos.Identity.JsonPatch.t(), keyword) ::
{:ok, OApi.Kratos.Identity.t()} | {:error, OApi.Client.Error.t()}
def patch_identity(id, body, opts \\ []) do
client = opts[:client] || @default_client
client.request(%{
args: [id: id, body: body],
call: {OApi.Kratos.Identity, :patch_identity},
url: "/admin/identities/#{id}",
body: body,
method: :patch,
# v this is correct! ( in a list)
request: [{"application/json", [{OApi.Kratos.Identity.JsonPatch, :t}]}],
response: [
{200, {OApi.Kratos.Identity, :t}},
{400, {OApi.Kratos.Error.Generic, :t}},
{404, {OApi.Kratos.Error.Generic, :t}},
{409, {OApi.Kratos.Error.Generic, :t}},
default: {OApi.Kratos.Error.Generic, :t}
],
opts: opts
})
end
So this is not a functional problem, just a spec one.
@aj-foster I reposted with context just so you know where to look. The inconsistency is in the generated code.
I think the exact location is this one:
Util.clean_list/1
swallows the list type via List.flatten/1
in it's implementation
A potential fix for this is in #33. If you have a chance, please let me know if it resolves the issue for you.
Hello again 👋🏼
Apologies, I meant #37 above. Release 0.1.0-rc.4 has changes to help with this. If you have a chance, please try it out and let me know how it works for you.
I'll use the same example as in #32, where i've added the comonent refs.
The typespec currently is:
I think the
@spec
for the second body argument should beOApi.Kratos.Identity.JsonPatch.t()
, not ~OApi.Kratos.Identity.JsonPatch.t()
~