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

Support for multiple server URL #65

Open
hackzaid opened this issue Oct 15, 2022 · 7 comments
Open

Support for multiple server URL #65

hackzaid opened this issue Oct 15, 2022 · 7 comments
Labels
question Further information is requested

Comments

@hackzaid
Copy link

Hi @miguelgrinberg I see in the core file there's support for multiple Server URLs or if I am mistaken with this line

# servers
        servers = [{'url': request.url_root}]

How do I set the second URL for instance if I want to set a sandbox and live server URL.

@miguelgrinberg
Copy link
Owner

You can manually edit the OpenAPI data blob in a process_apispec handler.

The documentation for the format is here. To add a server you will need to add your entry in the servers key. Something like this:

@apifairy.process_apispec
def my_apispec_processor(spec):
    spec['servers'][0]['description'] = 'Production server'
    spec['servers'].append({'url': 'https://staging.example.com', 'description': 'Staging server'})
    return spec

The first line adds a description to the main server (added by APIFairy automatically). The second line adds a second server, also with a description. The definition of what keys can be used to describe a server is here.

@miguelgrinberg miguelgrinberg added the question Further information is requested label Oct 15, 2022
@hackzaid
Copy link
Author

Thanks, this worked perfectly.

@hackzaid
Copy link
Author

Allow me to reopen this.

So, I have set all the neccessary URL for the API.

What is required is that I want to serve the docs on a different URL and maintain the API on the set Server URLs.

According to the documentation, you can set to serve the /docs URL with this configuration APIFAIRY_UI_PATH?

@hackzaid hackzaid reopened this Oct 19, 2022
@miguelgrinberg
Copy link
Owner

I'm sorry, but I don't understand what is the problem that needs addressing. Have you tried changing your docs URL? Is anything not working as documented?

@hackzaid
Copy link
Author

Exactly, I am looking for a way on how to serve the docs on a different URL, e.g: Host the API on api.somedomain.com and then access the docs on developer.somedomain.com.

@hackzaid
Copy link
Author

Not to forget, the FileField doesn't support multiple file uploads?

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Oct 19, 2022

You are going to have to serve your documentation yourself. Are you reading the documentation? This is all covered there: https://apifairy.readthedocs.io/en/latest/intro.html#using-a-custom-documentation-endpoint.

Not to forget, the FileField doesn't support multiple file uploads?

FileField represents one uploaded file.

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

2 participants