Comments (7)
Okay, digging into the code a little more now and I can see that the operationId is the view_func for Flask.add_url_rule.
I can also see that the Operation class uses a series of decorators to transform the view_func response. And according to line 126 of decorators/produces.py when I return a flask.Response object, the code decides to just return my response with no further processing.
So should I be looking at trying to add an additional decorator that will add extra headers? Would anyone be able to point me in the right direction here and I could try and get a pull request together for you next week?
Is this functionality you'd like to see added or should I be approaching this problem differently?
from connexion.
Do you want to have generic logic of adding the location header (e.g. pointing to "GET" of the same path when doing a PUT)? Where do you decide how to fill the "Location" header?
from connexion.
Hi,
So I am trying to find a way to return some headers of my own, along with the response body, from the view_func specified via the operationId. Perhaps some kind of decorator on the view function might work? Or alternatively maybe some kind of collection could be added as an attribute to the view function? So something like:
def my_view_func():
pass
my_view_func.headers = list_of_tuples
I'm not sure what would be the best approach. So adding a Location header is my use case here, but I think having the ability to return response headers as well as a response body would be useful in a range of different scenarios.
Does that make more sense to you now?
Dan
from connexion.
Hi there,
I've been thinking a bit more about this. I can see in the code that a tuple of length 2 is returned from the view function. I was thinking of modifying BaseSerializer.get_data_status_code to handle a tuple of length 2 or 3 - with the third element being a list of tuples of additional headers. Once the Response object has been generated, if the headers are not an empty list, then these headers are added to the response before Produces and Jsonifier return.
Would a technique like this of adding optional headers from the view function be of interest to you? If you like I could write this and open a pull request?
Dan
from connexion.
Okay, looks like I should have referenced this issue in my pull request to link this issue in. Since I didn't do that, here's the link:
Pull Request: #77
from connexion.
@danballance thanks for the PR, we'll check it 😄
from connexion.
#77 was already merged.
from connexion.
Related Issues (20)
- Frozen application can't run
- Maintenance release with less restrictive dependencies HOT 1
- How to add Prometheus client /metrics endpoint to Connexion 3.x AsyncApp? HOT 3
- Validation error with multipart/form-data and object type property HOT 1
- allOf doesn't work with multipart/form-data
- Arrays are parsed incorrectly with multipart/form-data HOT 1
- Release 3.0.6? HOT 4
- Add request as an optional kwarg to auth flow HOT 2
- Stream large file to AsyncApp (application/octet-stream) HOT 7
- Execution Order Issue: before_request Executing After x-apikeyInfoFunc Authentication Method HOT 1
- RoutingMiddleware should sort paths HOT 1
- Migrating to Connexion 3: Issues with current_app and g for Authentication and Request Lifecycle HOT 4
- g object is not accessible in x-bearerInfoFunc HOT 1
- Import issues when using editable install HOT 1
- Treats trailing slashes differently for swagger and normal endpoints HOT 2
- Missing API documentation HOT 2
- Document that ConnexionMiddleware might require to specifiy routes explicitly HOT 2
- Question: Using `validate_responses=True` in connexion 3.* HOT 1
- All defaults from all OneOf schema options get propagated using the DefaultJSONValidator
- swagger-ui not resolving external references
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from connexion.