Skip to content
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

[Elixir] Fix generation issues and compilation warnings in Elixir generator #18788

Merged
merged 13 commits into from
Jun 10, 2024

Conversation

ntodd
Copy link
Contributor

@ntodd ntodd commented May 29, 2024

This PR improves Elixir code generation by resolving several issues observed when generating using the Procore API spec:

  1. Previous reserved words list was incomplete. Updated to use the reserved words list from the Elixir language documentation.
  2. Reserved words were being prefixed with an underscore. In Elixir this indicates that the variable is not being used and when it is used it will emit a warning. This updates the renaming function to use a suffix to avoid these warnings.
  3. In rare cases, Typespecs were generating invalid types with a double "t" (e.g. ".t().t"). This change normalizes the names to improve reliability of the typespec generation.

@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 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (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.6.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.

@mrmstn mrmstn self-requested a review May 29, 2024 16:32
Copy link
Contributor

@mrmstn mrmstn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ntodd
Firstly, thank you very much for your contribution and effort on bringing the elixir openapi gen a bit more forward :)

Second, I'm not quite sure if the failing pipeline triggered an email for you, but it looks like you didn't update the sample (or may not committed them) according to the CI.

Other than that, your PR looks good to me except for the removal of the Pseudo-variables, which should be treated as reserved words as well. Thank you very much for your contribution and the effort you already put in :)!

@ntodd
Copy link
Contributor Author

ntodd commented Jun 5, 2024

@mrmstn I re-added the psuedo-variables and added __struct__ as well. I tweaked escapeReservedWord to better handle reserved words starting with underscores.

I did not address _ as @valpackett suggested. It could be added, but I'm not sure where to draw the line on what should be handled by the default list and what should be addressed by fixing --name-mappings functionality.

@mrmstn mrmstn self-assigned this Jun 9, 2024
@mrmstn mrmstn added this to the 7.7.0 milestone Jun 9, 2024
Copy link
Contributor

@mrmstn mrmstn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ntodd,
Thanks for your response and the updated code. I highly appreciated it and second, please excuse my longer response time, there's currently a lot going on, but I try me best to get the review squeezed in somewhere :)!

I looked through the generated samples, and it looks like the changes handle the primitive types not correctly for the type spec definitions!

Copy link
Contributor

@mrmstn mrmstn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ntodd,

I've made some changes to your code to get this PR moving forward. In my opinion, everything should be correct, but it would be great if you could review my changes to ensure I haven't missed anything.

If the changes look good to you, let's go ahead and merge this. If I don't hear back from you, I'll assume the changes are fine and plan to merge them by Tuesday.

The changes will be included in release 7.7.0. Alternatively, if you prefer to use the latest features, you can access them in the latest Docker container after the merge.

Thanks again for your time and effort! Your contributions are highly appreciated!

@ntodd
Copy link
Contributor Author

ntodd commented Jun 10, 2024

@mrmstn Thanks for catching what I missed. Looks good to me!

@mrmstn mrmstn merged commit 00f2cd5 into OpenAPITools:master Jun 10, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants