-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
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
I am working with the Microsoft Graph API specification (although I used yq -o=json eval openapi.yaml > openapi.json to convert to a JSON spec first, since there are too many Yaml code points for swagger-parser in v6.5.0 of openapi-generator). It has models named in the following format:
microsoft.graph.usermicrosoft.graph.authenticationMethodmicrosoft.graph.fido2AuthenticationMethod
etc. The Rust client generator is outputting the following warnings:
[main] WARN o.o.c.languages.AbstractRustCodegen - MicrosoftGraphFido2AuthenticationMethod cannot be used as a model name. Renamed to MicrosoftPeriodGraphPeriodFido2AuthenticationMethod
[main] WARN o.o.c.languages.AbstractRustCodegen - microsoft/graph/fido2_authentication_method cannot be used as a model file name. Renamed to microsoft_period_graph_period_fido2_authentication_method
This output is perplexing, as MicrosoftGraphFido2AuthenticationMethod post-sanitizing is completely legitimate for Rust, but it still performs another pass and adds Period in placements where . is in the original model name.
Likewise, the module file pathing microsoft/graph/fido2_authentication_method would be perfectly legitimate (assuming proper supporting mod.rs files were generated along the path) as a module path and file name. Or if not that microsoft_graph_fido2_authentication_method would be perfectly good as well, without the added _period separator in the module path name.
I realize these may be two separate issues, but since Period and _period are likely rooted with the same failing to handle . delimited model names, I bet they can be solved together.
openapi-generator version
6.5.0
OpenAPI declaration file content or url
https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/openapi/v1.0/openapi.yaml
converted to json with:
yq -o=json eval openapi.yaml > openapi.json
Generation Details
openapi-generator generate -g rust \
-i openapi.json \
-o ms-graph-rust \
--additional-properties=useSingleRequestParameter=true \
--skip-validate-spec
Steps to reproduce
- Download the openapi.yaml spec.
- Convert to openapi.json spec.
- Run the above command, see all of the WARN output.
Suggest a fix
I briefly reviewed the AbstractRustCodegen class and how its calling down into DefaultCodegen for various name sanitizing and character replacement, but didn't dig very deep. I feel like the owner of AbstractRustCodegen will know of a good way to handle this issue immediately after reading this description.