Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elixir generator AnyType support #14070

Closed
paulbalomiri opened this issue Nov 19, 2022 · 7 comments · Fixed by #14497
Closed

Elixir generator AnyType support #14070

paulbalomiri opened this issue Nov 19, 2022 · 7 comments · Fixed by #14497

Comments

@paulbalomiri
Copy link

Description

When compiling spec files which contain AnyType, the elixir generator expects a :struct type to be used in decoder.ex.

The generated code fails because no type <PKG>.Model.AnyType exists

Example Generated code found here:

defimpl Poison.Decoder, for: Ory.Model.OAuth2Client do
  import Ory.Deserializer
  def decode(value, options) do
    value
    |> deserialize(:jwks, :struct, Ory.Model.AnyType, options)
    |> deserialize(:metadata, :struct, Ory.Model.AnyType, options)
  end
end
openapi-generator version

6.0.3 to latest in main branch

Related issues/PRs

The proposed fix will reference this issue and builds on the latest work by @halostatue.

I also include the related elixir issues from #12731.

Suggest a fix/enhancement

When work on my branch is finished I intend to submit a PR

paulbalomiri added a commit to paulbalomiri/openapi-generator that referenced this issue Nov 19, 2022
@paulbalomiri
Copy link
Author

paulbalomiri commented Nov 20, 2022

I'm referring here to the discussion in the PR, which is better placed here, and in separate (future) related issues.

So there are 2 bugs here, and potentially a discussion

  1. recreate a PR branch by cherry picking:
    • for the AnyType specific changes (mapping to the bare json decoded value)

This is a feature addition, but without it this is a bug, as the non-existing AnyType is used (as <PKG>.Model.AnyType ) in the generated code:

https://github.com/ory/sdk/blob/958314d130922ad6f20f439b5230141a832231a5/clients/kratos/elixir/lib/ory/model/error_authenticator_assurance_level_not_satisfied.ex#L36-L41

  1. create a separate issue for the tesla/piping part, which is more a discussion whether there is a place for this approach in openapi-generator, in an additional generator, or in a separate custom template generarator repo.

@paulbalomiri
Copy link
Author

paulbalomiri commented Nov 20, 2022

@mrmstn, @halostatue so the two bugs in one PR, discussion separately is ok?

@halostatue
Copy link
Contributor

halostatue commented Nov 21, 2022

I think that the change of approach to fixed struct from piping should probably be a separate PR, as I’m not convinced that it’s a good change, personally. I generally treat Tesla.Env.t() as opaque.

@paulbalomiri
Copy link
Author

Will contribute this this weekend. [personal urgency]

@parkerduckworth
Copy link

Hello 👋 any update on this, by any chance? I'm running into the same issue with this elixir kratos client

@paulbalomiri
Copy link
Author

paulbalomiri commented Jan 3, 2023

Hi @parkerduckworth ,
No update for this issue, sorry. It's still on my "sonnish" list :)
In the meantime I'm using the bugfix_elixir branch from my fork from &deps/0 in mix.exs like so:

{:ory_hydra, github: "paulbalomiri/ory_sdk", sparse: "clients/hydra/elixir/", tag: "bugfix_elixir"},
{:ory_kratos, github: "paulbalomiri/ory_sdk", sparse: "clients/kratos/elixir/", tag: "bugfix_elixir"},

You could fork yourself, or use it directly, but it's not production grade.

@mrmstn
Copy link
Contributor

mrmstn commented Jan 24, 2023

Hi everyone, I was able to get some spare time to resolve this issue.

Thanks to everyone involved in this, specially @paulbalomiri for bringing this issue up and filling a draft for the issue. Also, a special thanks to @halostatue for the reviews and discussions, I highly appreciate it.

The fix will be shipped in version 6.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants