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

[Rust Server] Allow more than 32 configured paths #3494

Merged
merged 1 commit into from
Aug 4, 2019
Merged

[Rust Server] Allow more than 32 configured paths #3494

merged 1 commit into from
Aug 4, 2019

Conversation

richardwhiuk
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

@bjgill @farcaller @frol

Description of the PR

Currently the Rust Server generator uses an array to store the paths available on an API.

If the API has more than 32 configured paths, then the produced API fails to compile with:

error[E0277]: `&[&str; 37]` is not an iterator
   --> src/server/mod.rs:113:60
    |
113 |         pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(&[
    |                                                            ^^^^^^^^^^^^^^^^^^^^ `&[&str; 37]` is not an iterator
    |
    = help: the trait `std::iter::Iterator` is not implemented for `&[&str; 37]`
    = note: required because of the requirements on the impl of `std::iter::IntoIterator` for `&[&str; 37]`
    = note: required by `server::paths::regex::RegexSet::new`

This is because Iterator is only implemented for arrays up to 32 in size.

This change avoids that limitation by moving to using a Vec, and adds a test API to the Rust Server tests which has 33 paths, to avoid hitting this limit again.

Copy link
Contributor

@bjgill bjgill left a comment

Choose a reason for hiding this comment

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

Nice - I assume this is the fix for #314?

One very optional comment.

Also, for future reference, this sort of thing would be easier to review if the sample (re)generation was in a separate commit.

(BTW, welcome to the technical committee 👋)

@richardwhiuk richardwhiuk merged commit 83f1794 into OpenAPITools:master Aug 4, 2019
@richardwhiuk richardwhiuk deleted the rust-32-paths branch August 4, 2019 11:55
@wing328 wing328 added this to the 4.1.0 milestone Aug 9, 2019
# 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.

3 participants