beam-community / stripity-stripe

An Elixir Library for Stripe
Other
965 stars 344 forks source link

Stripe.Account.create has an incomplete spec #818

Closed michelboaventura closed 9 months ago

michelboaventura commented 10 months ago

Package Version

3.0.0

Are you using the latest version?

Steps to Reproduce

Stripe's created account allows us to pass card_payments as a capability as described here, but stripity-stripe's type on the same function doesn't include it here.

So if you call:

Stripe.Account.create(%{capabilities: %{card_payments: %{requested: true}}))

Expected Result

Dialyzer shouldn't complain.

Actual Result

I got this dialyzer error:

image
michelboaventura commented 10 months ago

If my suspicious is correct I'm more than glad to create a PR fixing the types.

yordis commented 10 months ago

PR welcome for sure!

michelboaventura commented 10 months ago

Since the files are being generated by the openapi specs, how should I address this on the code?

yordis commented 10 months ago
  1. Figure out if this is a limitation of the existing OpenAPI Spec
  2. If it is not an OpenAPI Spec limitation 2.1 Modify the code to produce better outcome
maartenvanvliet commented 10 months ago

The issue stems in a heuristic used to resolve named parameters in inputs to spec types. When the name matches it will use that to set a reference to the related type, apparently this does not work in this particular case.

To make it work properly I think we'll need another pass to first collect all the types to check whether the references are correct.

However, it might me more feasible to simply disable the part where the references are created. There resulting types will be weaker. In the case of capabilities it will become: optional(:capabilities) => map(), but it will be correct. Later on a better method can be found.

This should be enough to fix it.

@@ -73,7 +74,7 @@ defmodule Stripe.OpenApi.Phases.Compile do
               quote do
                 @spec unquote(function_name)(
                         unquote_splicing(argument_specs),
-                        params :: unquote(to_inline_spec(param_specs)),
+                        params :: unquote(to_inline_spec(params)),
                         opts :: Keyword.t()
                       ) ::
                         {:ok, unquote(success_response_spec)}
github-actions[bot] commented 9 months ago

This issue has been automatically marked as "stale:discard". If this issue still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment.

github-actions[bot] commented 9 months ago

Closing this issue after a prolonged period of inactivity. If this issue is still relevant, feel free to re-open the issue. Thank you!