swagger vendor tags, host, path tags#163
Conversation
|
I don't have a python 3 environment. I"m trying to get one to get it to build again. I have no idea why parts that I didn't have anything to do with are breaking. |
|
Thanks ! I'll start reviewing today (after I released the 0.9.1). From what I see, you'll be needing:
About Python 3, what OS are you using ?
Once they are installed, use |
| :param str contact: A contact email for the API (used in Swagger documentation) | ||
| :param str license: The license associated to the API (used in Swagger documentation) | ||
| :param str license_url: The license page URL (used in Swagger documentation) | ||
| :param str host: The host that the api is running on. Not always the localhost, thought it is the default. |
There was a problem hiding this comment.
There is many closed issue on the host subject (ex: #132, #155, #128, #54).
You should have to enter it manually as Flask already handle this properly. If you have to specify the host elsewhere from the SERVER_NAME setting, it's propably that you're lacking the ProxyFix
I should had a dedicated section in the documentation in addition to the examples (https://github.com/noirbizarre/flask-restplus/blob/master/examples/complex.py)
There was a problem hiding this comment.
I am still a bit confused by this. I have added:
from werkzeug.contrib.fixers import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app)
to my code and it does not return a host in the swagger doc.
{
basePath: "/v1",
consumes: [
"application/json"
],
info: {
description: "API Interface",
title: "Tudor Instrument API",
version: "1.0.0"
},
paths: {},
produces: [],
responses: {},
swagger: "2.0",
tags: []
}
When setting SERVER_NAME explicitly it causes errors. (404)
Could you elaborate on how that should work.
Also, I want to re-confirm the use case.
We are generating a swagger document. Storing in a mongo db. Calling it from another location for dynamic function generation.
It looks to me like if I am setting SERVER_NAME it impacts the routing. I was hoping for a solution where the app behavior isn't driven by the doc.
That said, I don't have a huge amount of experience in this area. Could you provide a bit more clarification on:
- how the proxy fix should behave
- whether I can have a completely arbitrary host name
|
In response to the higher level question. I am using Rhel 6.5 (can be 7) I got most of the above working. I have one issue unfortunately with the tests. Nosetests pass while the tox tests fail. I'm not sure of why/where that is. I'm still trying to figureout how to identify the bug. with the python 3 code. |
|
This may be a religious issue here, but is it possible to disable a feature for python 3 if it's only functional in 2? |
|
@bedge |
|
@kmalyar-tic I rebased your work to master with python 3 disabled, just to see if everything else still passed. |
|
@kmalyar-tic I took a pass at the python3 stuff and just merged in some 2to3 recommendations and it fixed the failing pythin3 unit tests. |
|
Sorry for the late response. I think you should rebase on latest master to make it pass. Great for the tag part, but for the host part, I think it should be in because Flask already provide all necessary to proprely specify host. Losts of Flask internals relies on it and I don't want to monkeypatch or bypass this part as it leads to lots of inconsistency. |
|
Will do my best to get this working this weekend :) Thanks! I understand a desire not to monkey patch. With our use case, we are generating the swagger docs, but they they are being collected elsewhere. Not only that, but they are also aliased due to load balancers. I know that Flask provides some information on how to properly specify host, but trying that, it did not then work running the service. Can you help me out with an example of how that should happen? I'm relatively new. The approach I took was to just add that one tag to make it config driven more than fiddling with either nginx configs or some environment variables. |
|
@bedge Thanks again! Thats awesome, I appreciate it |
|
Hi @noirbizarre , I think I've finally wrapped my head around our disconnect. I can appreciate the proxy fix solution you've provided. I've gotten it sorta working on my side, but it doesn't actually fit my needs. Here's the difference: We are using the library to generate swagger docs and then publish to an api hub. The host itself doesn't know what its CNAME is. We gather these these docs and use them for code generation in other places to make web requests through the load balancer. I don't have any control over the load balancer, we can't touch it. Proxying the request is fine, but I need to have a config driven url for the host. Any change to the flask configs breaks the service functionality. Maybe I can persuade you? :) Either that, or maybe you can help with a better example, the simple ProxyFix doesn't do it. It doesn't generate the doc correctly. Either way, if no, no harm done. I'll withdraw this peice of functionality and recreate a pull request with just vendor and path tags. Thanks! |
Hi!
I just got approval for this internally. I've taken the latest pull and run with that:
........................................................................
.............................................................................
....
851 tests run in 2.8 seconds (851 tests passed)
3 changes that I made was to allow for
custom tags to be added at the path level
3rd party vendor fields
having an explicit hostname added to the document (Example is if the doc or swagger ui should be communicating with a host and not running the service local to the doc)
I ran nosetests and they all executed
This is my first attempt at a pull request, so please, be gentle.
Regards,
Kelvin