Skip to content

Commit

Permalink
Improved Elixir Atom Generation (#20229)
Browse files Browse the repository at this point in the history
* Update ElixirClientCodegen.java

* 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`

* Add model to petstore client to test new atom creation regex pattern
  • Loading branch information
drewble authored Dec 6, 2024
1 parent 52b5b8f commit ba5ecbc
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public class ElixirClientCodegen extends DefaultCodegen {
private final Logger LOGGER = LoggerFactory.getLogger(ElixirClientCodegen.class);

private final Pattern simpleAtomPattern = Pattern.compile("\\A(?:(?:[_@\\p{Alpha}][_@\\p{Alnum}]*[?!]?)|-)\\z");
private final Pattern simpleAtomPattern = Pattern.compile("\\A(?:(?:[_\\p{Alpha}][_@\\p{Alnum}]*[?!]?)|-|@)\\z");

@Setter protected String packageVersion = "1.0.0";
@Setter protected String moduleName;
Expand Down
Loading

0 comments on commit ba5ecbc

Please # to comment.