Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improved Elixir Atom Generation #20229

Merged
merged 3 commits into from
Dec 6, 2024
Merged

Conversation

drewble
Copy link
Contributor

@drewble drewble commented Dec 3, 2024

  • Refine the regular expression for atoms

The current regex incorrectly matches @atom (unquoted atoms cannot begin with @). However, through testing with iex, it also turns out that the atom :@ is legal.

The following atoms will now be quoted that would have been incorrectly not quoted:

  • :"@type"

@mrmstn

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.

* Refine the regular expression for atoms

The original regex incorrectly matched `@atom` (unquoted atoms
cannot begin with @). However, through testing with `iex`, it also turns out that the atom
`:@` is legal.

The following atoms will now be quoted that would have been
incorrectly not quoted:

- `:@type`
@wing328
Copy link
Member

wing328 commented Dec 4, 2024

@drewble thanks for the PR

I just merged #20236 to create a seaprate spec to test Elixir client generator.

Can you please merge the latest into your branch and add a test or 2 in the test spec(modules/openapi-generator/src/test/resources/3_0/elixir/petstore-with-fake-endpoints-models-for-testing.yaml), and then regenerate the samples?

@drewble
Copy link
Contributor Author

drewble commented Dec 5, 2024

@wing328 I believe I have completed the updates as requested, with additions to the test spec, and an additional ExUnit test for the new Any model containing a quoted atom key.

@wing328
Copy link
Member

wing328 commented Dec 6, 2024

tested locally and the result is good

Compiling 1 file (.ex)
Generated openapi_petstore app
Running ExUnit with seed: 226276, max_cases: 16

...........
Finished in 0.2 seconds (0.2s async, 0.00s sync)
11 tests, 0 failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.616 s
[INFO] Finished at: 2024-12-06T14:25:20+08:00
[INFO] ------------------------------------------------------------------------

@wing328 wing328 merged commit ba5ecbc into OpenAPITools:master Dec 6, 2024
16 checks passed
@wing328 wing328 added this to the 7.11.0 milestone Dec 6, 2024
@drewble drewble deleted the patch-1 branch December 6, 2024 15:08
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants