ory / sdk

The place where ORY's SDKs are being auto-generated
Apache License 2.0
141 stars 85 forks source link

clients/client/elixir refers to an unavailable application #194

Open halostatue opened 2 years ago

halostatue commented 2 years ago

Preflight checklist

Describe the bug

When compiling clients/client/elixir, the following message is printed:

You have configured application :ory_apis in your configuration file,
but the application is not available.

This usually means one of:

  1. You have not added the application as a dependency in a mix.exs file.

  2. You are configuring an application that does not really exist.

Please ensure :ory_apis exists or remove the configuration.

The documentation also refers to this:

## Configuration

You can override the URL of your server (e.g. if you have a separate development and production
server in your configuration files.

    config :ory_apis, base_url: "https://playground.projects.oryapis.com"

However, mix.exs calls the application :ory_client, which is the name that should be used in the configuration and examples.

I haven’t played with the code generation process, so I am not sure where :ory_apis vs :ory_client is coming from, but it is an issue.

Reproducing the bug

$ mix do deps.get, compile

Relevant log output

No response

Relevant configuration

No response

Version

n/a

On which operating system are you observing this issue?

No response

In which environment are you deploying?

No response

Additional Context

No response

aeneasr commented 2 years ago

Interesting find, I have no idea where this problem is coming from. Could it be a bug in the OpenAPI Generator itself?

If so, could you please raise an issue and/or fix with them and link the issue here? :)

halostatue commented 2 years ago

I’ve been playing with openapi-generator for other issues. One of my fixes will be in 6.0.1, which will reduce the number of warnings generated from hundreds to one. The other which will eliminate that one will be in the next week or two—it is a more involved change.

I didn’t see any instructions on how to generate clients to test this, but this feels like (either) a configuration error or an OpenAPI specification error. If you have any instructions, I can try generating the code locally to see if the error persists. I also couldn’t quite figure out how the incorrect application specification showed up.

aeneasr commented 2 years ago

Thank you! You can test this out by cloning the repo, going into the project root, and follow: https://github.com/ory/sdk#debugging-failing-circleci-tests

halostatue commented 2 years ago

Just as a note, I believe that this will be fixed with OpenAPITools/openapi-generator#12775.

aeneasr commented 2 years ago

Nice! We’ll be watching out for that one - thank you for the detailed issue!

paulbalomiri commented 1 year ago

Is the generator output already in this repo?

I'm a bit confused about the clients/client directory vs clients/{hydra,kratos,...} directories, the latter containing only service-specific code. All those packages redefine common modules such as Ory.Connection, which makes it impossible to depend on more than one of the generated packages (ory_client, ory_kratos, ...)

@halostatue i'd like to know:

I'm trying to get my project to use hydra and kratos apis. Thank you for the patch, it is much better now, as e.g. use auth for admin is settable on Ory.Connection, previously i had to reimplement the calls for that.

Also I have a question regarding packaging & versioning: I see that the hex package with version 0.2.0-alpha.60 is published on hex. if ory_client is the way to go, is there a way to know which versions of kratos,hydra e.t.c were the base for the generated code?

Thanks for @halostatue, and of course to ory for your work!

halostatue commented 1 year ago

I haven't looked at Ory since July, and I’m currently on vacation. The most recent version of openapi-generator should be reporting a few more details about what it was generated with from the OpenAPI file…but I don’t know about the current status of this.

paulbalomiri commented 1 year ago

Thanks, will fork and try to configure the generator to non-colliding package names. I'll open a separate ticket if that yields some success. I'm thinking of changing invokerPackage to a new variable Ory.${ELIXIR_CAMELIZED_PACKAGE_NAME} here:

https://github.com/ory/sdk/blob/2324e5c13c45d43c7e7b3cdc5ebc86b86b627867/config/client/elixir.yml#L1-L3

Happy Holydays @halostatue 🥳 !