Skip to content

[fix][elixir] simplify connection module #21158

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

Merged
merged 1 commit into from
May 4, 2025

Conversation

efcasado
Copy link
Contributor

@efcasado efcasado commented Apr 27, 2025

Description

This PR simplifies the generated Connection module according to the discussion here. The new approach is more idiomatic and improves the maintainability of the generator.

Additionally, it resolves the issue reported in #20562 by removing the problematic function specification from the generated code. The issue can be reproduced using Stripe's OpenAPI specification, available here.

== Compilation error in file lib/connection.ex ==
** (MismatchedDelimiterError) mismatched delimiter found on lib/connection.ex:92:45:
    error: unexpected token: )
    │
  4 │ defmodule Stripe.Connection do
    │                             └ unclosed delimiter
 ...
 92 │   @spec new(String.t(), String.t()), options) :: Tesla.Env.client()
    │                                             └ mismatched closing delimiter (expected "end")
    │
    └─ lib/connection.ex:92:45
    (elixir 1.18.3) lib/kernel/parallel_compiler.ex:428: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8

With these changes, #15075 becomes unnecessary.

I considered targeting the 8.0.x branch, but since the Elixir generator is still in alpha and this change also fixes a known issue, I believe it makes more sense to target master directly. What do you think?

As usual, curious to hear your thoughts @mrmstn and @wing328 😊

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@efcasado efcasado force-pushed the improve-connection-new branch from 304ba31 to 5826c14 Compare April 27, 2025 12:15
@efcasado efcasado marked this pull request as ready for review April 27, 2025 12:44
@efcasado efcasado force-pushed the improve-connection-new branch from 5826c14 to e363748 Compare April 27, 2025 13:46
@efcasado efcasado force-pushed the improve-connection-new branch from e363748 to e1b49a2 Compare April 27, 2025 14:29
@wing328 wing328 added Client: Elixir Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc. labels Apr 28, 2025
@wing328 wing328 added this to the 7.14.0 milestone Apr 28, 2025
@wing328
Copy link
Member

wing328 commented Apr 29, 2025

thanks for the pr

we can consider this a bug fix to start with.

if later users need the old behaviour, we can try to come up with a way to fallback

@wing328 wing328 merged commit 0389a99 into OpenAPITools:master May 4, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client: Elixir Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc. Issue: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants