-
Notifications
You must be signed in to change notification settings - Fork 162
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
ConnexionPrometheusMetrics - mimetype #64
Comments
Hm, that's interesting, not sure how it's handled there implicitly. Thanks for reporting!
|
This probably refers to the possibility of defining endpoints like this:
But I tried this already this is not recognized by the function itself. I think this makes the API call the response function with:
If the function is called with that it will work. I thought about an additional kwargs parameter like you added it before. But the problem there would be that maybe not every Endpoint has the same response type... |
I think I saw the default mimetype set to json in the Connexion source code, maybe that's what's missing here. I'm starting to have some doubts whether I implemented the decorators the right way here (as they seem to process the response before the wrapping framework), so I might have a look at that later this week, time permitting. Until then, the best I could offer is to switch back to plain Thanks again for reporting it, and for providing examples! 🙏 |
So, I couldn't solve this properly, but I made it closer to the Connexion defaults. Unfortunately, the actual mimetype (based on the content types in the OpenAPI spec) are quite well hidden in Connexion and I couldn't find a way to look those up at runtime. :( @metrics.content_type('text/plain')
@metrics.counter('test_plain', 'Counter for plain responses')
def plain() -> str:
return 'Test plain response' It's not very good, but it does work around the issue. If I have time, I might see whether we could integrate the OpenAPI spec parsing from Connexion and perhaps we could pick the default content type from there, but I feel like it's never going to be 100% What do you think @Echronix does this provide any usefulness for what you use Connexion for, for example? |
Hey there,
sorry that I bother you again. The new Connexion release works mostly fine with my Code but I discovered a new problem.
Calling the get_response method from Connexion without mimetype as parameter leads to the warning:
That also leads to the problem, that the response.json part is equal None and API response can only be found in the response.data part.
Setup:
Updated example from last time:
Expected behaviour:
Actual behaviour:
The fact that the content-type is not application/json sadly breaks some API callers.
The text was updated successfully, but these errors were encountered: