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

Generated Elixir module names clash #229

Open
4 of 6 tasks
paulbalomiri opened this issue Nov 17, 2022 · 3 comments
Open
4 of 6 tasks

Generated Elixir module names clash #229

paulbalomiri opened this issue Nov 17, 2022 · 3 comments
Labels
bug Something is not working.

Comments

@paulbalomiri
Copy link

paulbalomiri commented Nov 17, 2022

Preflight checklist

Bug Description

Generated Elixir module names such as Ory.Connection clash. Elixir dependencies cannot override each other's Modules, but the generated code does contain the same module name in different dependencies:

Examples:

defmodule Ory.Connection do

defmodule Ory.Connection do

defmodule Ory.Connection do

defmodule Ory.Connection do

defmodule Ory.Connection do

defmodule Ory.Connection do

This is a follwup to this comment #194 (comment)

Reproducing the bug

Create any library importing e.g. at least 2 packages:
Example snippet from mix.exs:

defp deps do
    [
     ...
      {:ory_client, github: "ory/sdk", sparse: "clients/client/elixir/"},
      {:ory_hydra, github: "ory/sdk", sparse: "clients/hydra/elixir/"}
     ]
  end

Relevant log output

when building/running lots of warnings such as this one is logged:

warning: redefining module Ory.Connection (current version loaded from /workspace/cantex_umbrella/_build/dev/lib/ory_client/ebin/Elixir.Ory.Connection.beam)
  lib/ory/connection.ex:5

Relevant configuration

Here is the Variable setting, to which I propose to add this line:

export ELIXIR_INVOKER_MODULE="Ory.${PROJECT^}"

export ELIXIR_PACKAGE_NAME="ory_${PROJECT}"

And here the line 3 should be changed to

invokerPackage: ${ELIXIR_INVOKER_MODULE}

packageName: ${ELIXIR_PACKAGE_NAME}
packageVersion: $RAW_VERSION
invokerPackage: Ory

This results in package names such as Ory.Hydra.Connection

Version

latest stable versions

Additional Context

@aeneasr I'm putting here the questions I have for understanding & documentation, These are mostly issues to get the PR right.

  • How shall a PR be formulated? I'm thinking about a multi commit PR, one commit comprising the config changes, another one with each package.?
  • Does the build pipeline build all clients, all the time?
  • Are the old spec vertions built too?
  • How does the spec version map to package versions generally [if there's a rule/docs]?
  • Is there such a thing as an [aglorithmic] sdk version ?

I'll come back with a PR on this, I've already forked the sdk. The bug is easy to solve, but perhaps a followup documentation issue would benefit from those questions.

It's a rather long post, so feel free to only discuss in context of the upcoming PR.

@paulbalomiri paulbalomiri added the bug Something is not working. label Nov 17, 2022
@paulbalomiri paulbalomiri changed the title Elixir client libs have Module name clashes between each other Generated Elixir module names such clash Nov 17, 2022
@paulbalomiri paulbalomiri changed the title Generated Elixir module names such clash Generated Elixir module names clash Nov 17, 2022
paulbalomiri added a commit to paulbalomiri/ory_sdk that referenced this issue Nov 17, 2022
paulbalomiri added a commit to paulbalomiri/ory_sdk that referenced this issue Nov 17, 2022
paulbalomiri added a commit to paulbalomiri/ory_sdk that referenced this issue Nov 17, 2022
@paulbalomiri
Copy link
Author

paulbalomiri commented Nov 19, 2022

I have created this upstream PR to Openapi-generator

I might transform the changes, or do a complete rewrite of the generator into a custom generator for this project if the pain pressure gets too high, as i'm planning to use all apis from elixir in a self-deployed setup.

@aeneasr
Copy link
Member

aeneasr commented Nov 21, 2022

Awesome, thank you so much for your work @paulbalomiri :) Please let me know how it goes :)

@paulbalomiri
Copy link
Author

paulbalomiri commented Nov 21, 2022

I have some personal urgency until thursday. In the meantime i'll find out whether this will be a custom generator or i can formulate an upstream PR to openapi-generator.
I think i'll know this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

2 participants