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

Is there a way to sort in the automated documentation? #604

Open
macnewbold opened this issue Apr 26, 2024 · 1 comment
Open

Is there a way to sort in the automated documentation? #604

macnewbold opened this issue Apr 26, 2024 · 1 comment
Labels
question Further information is requested

Comments

@macnewbold
Copy link

I'm hoping I'm just missing something, but as our project grows, we're trying to keep the documentation as easy to use as we can. One way we do this is by sorting our ~20 namespaces alphabetically as we load them, so that they come out in the same order they were loaded. While it would be nice if this was automatic, it's workable.

We have an issue though with our 40+ models, whose names alone scroll across several screenfuls in the docs in the browser. They are listed in the order they were added, which means whatever models are used in the early methods of the earliest loaded namespaces show up first. Rather than having models load into the documentation in the order they were used/added as we processed all the methods, we would love to have a way to sort the models alphabetically. Or failing that, listing each model's namespace with it would help it make more sense regarding where to find stuff without resorting to text searches in the browser.

Some other implementations of swagger-related documentation like this seem to support a "sorter" method that can be provided to determine the sort order that is desired in the output.

Thanks to all the contributors and maintainers for the great project!

@macnewbold macnewbold added the question Further information is requested label Apr 26, 2024
@macnewbold
Copy link
Author

If it helps any, I did find this great article about a way to automatically sort namespaces by subclassing the API:

https://obikastanya.medium.com/flask-restx-plus-sort-namespace-in-swagger-a5e3c8fab08a

If there were something similar to this for both namespaces and models, it would work great I think.

Another option that I'm very open to is having the sorting be a display thing when the docs are generated, and not worrying about any internal sorting in the core. The order really only matters when you display it to a user I think, so a display-level solution would work fine, if it includes the web-based docs and the swagger json output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant