Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #14070
Something went wrong while setting issue due date.
Closed
Open
Issue created 2 years ago by Administrator@rootContributor
  • New related issue

  • Report abuse to administrator

  • New related issue

  • Report abuse to administrator

Elixir generator `AnyType` support

Closed

Elixir generator `AnyType` support

Created by: paulbalomiri

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.

  • #12731 (closed)
  • #12775

I also include the related elixir issues from #12731 (closed).

  • #12484 (closed)
  • #4011 Still there is no elixir test suite
  • #8804
  • #12268
Suggest a fix/enhancement

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

An error occurred while loading designs. Please try again.
Tasks
0
server returned results with length 5, expected length of 9

Linked items
0

Link issues together to show that they're related. Learn more.

Activity


  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: paulbalomiri

    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

    • change the header field name handling using some form of Kernel.to_string/1, as Tesla.put_header/3 (doc) expects a binary() not an atom() as key argument, as is proposed here:
      https://github.com/OpenAPITools/openapi-generator/blob/f0625b83fbbb90036d6ce983fa738274aedbd625/samples/client/petstore/elixir/lib/openapi_petstore/request_builder.ex#L105-L108
    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.
  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: paulbalomiri

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

  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: halostatue

    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.

  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: paulbalomiri

    Will contribute this this weekend. [personal urgency]

  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: parkerduckworth

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

  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: paulbalomiri

    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.

  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: mrmstn

    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.

Please register or sign in to reply
0 Assignees
None
Assign to
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
Due date
None
None
None
Time tracking
No estimate or time spent
Confidentiality
Not confidential
Not confidential

You are going to turn on confidentiality. Only project members with at least the Reporter role, the author, and assignees can view or be notified about this issue.

Lock issue
Unlocked
0
0 participants
Reference:

Menu

Explore Projects Groups Snippets