-
Notifications
You must be signed in to change notification settings - Fork 57
Best way to handle "application/problem+json" #114
Comments
I wouldn't create a new pip package, or PR into this repo, but you would need have a custom codec to deal with
It's possible that we could consider including |
Thanks, Dan! |
Okay thanks, that will work fine I guess. Although It's not going to be quite as "plug-and-play" for our customers then because I'm going to need to provide an additional decoder class before they can access our API properly. So I guess I will lean towards providing an example client that they can install from pip/github that sets CoreAPI up correctly for them with this additional class. In terms of non-error responses I am returning application/hal+json hypermedia resources. For the API schema itself I'm using OAI/Swagger2. I have built a kind of in-house schema on top of these formats that we're using internally to automate a lot of the repetitive boiler plate required for many API operations. It's working pretty nicely so far - lots of automatic code generation of the API server code as well as client libraries such as Core API working, pretty much, out of the box. There are always one or two teething issues to solve though. The next one actually is authentication. My API is using the OAuth2 password flow. Are there any plugin options for authentication or is this something I'll need to add myself? |
On second thoughts maybe we could provide this built-in. (Or something like have the default decoders automatically be whatever plugins are available, so that it's only a pip install away, and nothing else)
At the moment the best you'd get would be adding the auth endpoints to the scheme, tho you'd still need to create a new client once you do have the auth token. And yes, addressing this is absolutely on the list. |
Thinking about this a little further, maybe for now I will go down the route of a separate pip package then - even though the code will be ridiculously trivial. As you say, it's just a pip install away and I can still point people directly to this project and just say in the docs that they need to ensure they install a specific list of pip packages with it. Edit: I'm here actually meaning a pip package that can be installed from github - that probably I'll just include in a requirements.txt file. I'm not meaning an official pip package. In terms of authentication, since this PR in the Swagger-UI project my users can now authenticate directly in Swagger-UI when they are exploring the API. (Which is pretty cool!) I'll have to have a think about what I can do here in the meantime in terms of authenticating our customers with CoreAPI - obviously authenticating to the API is an absolutely critical feature. Is it worth me opening an issue for authentication plugins or do you have this covered off elsewhere? thanks for your help and prompt replies! |
Opening the issue makes sense, yup. There's a coupla different issues worth talking through there:
|
In terms of workarounds or interim solutions, I've noticed that I can pass in credentials to the client via the transports list. This is just a simple test, but this authenticates me okay to my local dev server.
Is there any chance you could explain a little more about the credentials variable/attribute and the purpose behind the host check? I'm just wondering if I can find a way to piggy back on this somehow. Perhaps the token generation and caching could be done outside of CoreAPI for now and the client is then instantiated with a transport that has a bearer token ready to go. It's not ideal but it might be okay as a workaround until #115 is complete. |
Final comment for the day from me :) So I've decided to import a set up function that makes things nice and easy for our customers. This particular use case is for the example/tutorial section from our API docs and for this section at least I want things to be really easy without needing to understand too much about how things are working internally. I end up with example code like the following that seems to work for my purposes:
Happy days. |
Hi there,
The framework I am using (https://github.com/zalando/connexion) returns validation errors as Content-Type "application/problem+json" (https://tools.ietf.org/html/rfc7807) and this generates an error for me using Core API:
As a kind of hackish test, I have created a file jsonproblem.py to make available a new codec JSONProbemCodec which does nothing apart from provide a different media type:
So my question is two-fold really.
Any advice appreciated. I'm keen to recommend coreapi as a simple python interface for our customers to use with our new API, but I just need to iron a few teething issues first. This is the first issue I have hit during testing.
The text was updated successfully, but these errors were encountered: