ory / sdk

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

Elixir #189

Closed aeneasr closed 2 years ago

aeneasr commented 2 years ago

Related Issue or Design Document

Checklist

Further comments

aeneasr commented 2 years ago

@tobbbles

So I was able to get this almost working. But it's not working yet, I need your help here. Here is what I did:

  1. check out this branch
  2. Run:
    
    docker build --platform linux/amd64 -t oryd/sdk:latest .
    docker run --platform linux/amd64 --mount type=bind,source="$(pwd)",target=/project -it oryd/sdk:latest /bin/sh

export FORCE_VERSION=v1.11.0 export FORCE_PROJECT=hydra cd /project

./scripts/generate.sh ./scripts/test.sh

cd clients/hydra/elixir

mix local.rebar --force mix local.hex --force mix deps.get

export HEX_API_KEY=THISDOESNOTMATTERYET mix hex.publish --yes --dry-run


This will then fail due to multiple reasons. One of them of course is that the api key is wrong. But the problem is that it wants to build some docs, which do not seem to be included:

warning: found quoted atom "userinfo_signing_alg_values_supported" but the quotes are not required. Atoms made exclusively of ASCII letters, numbers, underscores, and optionally ending with ! or ? do not require quotes lib/ory/model/well_known.ex:68:5

Generated ory_hydra app Publication failed because the "docs" task is unavailable. You may resolve this by:

  1. Adding {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} to your dependencies in your mix.exs and trying again
  2. If ex_doc was already added, make sure you run "mix hex.publish" in the same environment as the ex_doc package
  3. Publishing the package without docs by running "mix hex.publish package" (not recommended)

** (Mix) The task "docs" could not be found. Did you mean "do"?



For now, I worked around this with: `mix hex.publish package` but it says it's not recommended. How can we fix the docs task?
tobbbles commented 2 years ago

Nice!

Hmm that's an interesting one, likely it's an issue with the upstream open api generator missing this package; I'll investigate a little deeper when I get to a machine.

tobbbles commented 2 years ago

So, unfortunately it doesn't look like there's a trivial way to add extra dependencies to the generated Elixir projects without ripping open the openapi-generator source 😞

I'm thinking either A) We provide a custom mix.exs.mustache file to enable finer control over the package details, such as adding extra dependencies, but also further things like licenses, links, source urls, etc. https://hex.pm/docs/publish#adding-metadata-to-code-classinlinemixexscode B) We script adding the ex_doc dependency to mix.ex as a post-generation step.

A is more desirable but will require more maintenance, as we don't get upstream changes to the mix.exs template; however it looks like it gets about 4 commits per year 😄

aeneasr commented 2 years ago

I think we could get those changes merged upstream in OpenAPI Generator quite swiftly, especially since publishing currently doesn't work without workarounds!

tobbbles commented 2 years ago

Opened an upstream issue to track this and gather input on one of two proposed solutions; let's see if we get any feedback, if not then we could make an assumption and look to go with the simpler change, or just 'brute force' including the ex_doc dependency in openapi-generator templates

aeneasr commented 2 years ago

Awesome, thank you!