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

[BUG] [Elixir] Invalid client module names generated from Paypal API spec #20505

Open
5 of 6 tasks
aparod opened this issue Jan 20, 2025 · 1 comment
Open
5 of 6 tasks

Comments

@aparod
Copy link

aparod commented Jan 20, 2025

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating an Elixir client using Paypal's OpenAPI spec files, invalid module names are sometimes created. This prevents the application from compiling.

Actual: defmodule Orders.Model.400DetailsInner do

Expected: uncertain.

  • Every part of a module name separated by a . must begin with an upper-case letter. So, prefixing the 400DetailsInner portion with something arbitrary like X would work: defmodule Orders.Model.X400DetailsInner do.
  • Alternatively, module names are just atoms that start with Elixir. Creating modules (and referencing them throughout the code base) like this should work: :"Elixir.Orders.Model.400DetailsInner"
  • There may be another, better solution that I'm not thinking of.
openapi-generator version

latest

OpenAPI declaration file content or url

https://github.com/paypal/paypal-rest-api-specifications/blob/main/openapi/checkout_orders_v2.json

Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest generate \
    -i /local/checkout_orders_v2.json \
    -g elixir \
    -o /local/out/
Steps to reproduce
  1. git clone [email protected]:paypal/paypal-rest-api-specifications.git
  2. cd paypal-rest-api-specifications/openapi
  3. Run the above generation command
  4. less out/lib/orders/model/_400_details_inner.ex
  5. Observe invalid module definition: defmodule Orders.Model.400DetailsInner do
Related issues/PRs
Suggest a fix

See above.

@aparod aparod changed the title [BUG] [Elixir] Invalid client module names generate from Paypal API spec [BUG] [Elixir] Invalid client module names generated from Paypal API spec Jan 20, 2025
@wing328
Copy link
Member

wing328 commented Jan 20, 2025

as a workaround, you can use the modelNameMapping option to rename the model to something else

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#name-mapping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants