How can I group the endpoints by Party ? Which declaration/annotation comment should I use ? I'm having this:
I need the endpoints to be grouped by something like "Books", "Catalogs" and so on,... not one unique unnamed "default" group. How can I achieve that?
PS: My problem is similar to this link, but I'm using Iris-Go, and this plug-in.
UPDATE1
.json file
Iris-go uses gin-swagger/swaggo under the hood. In Swagger to get endpoints grouped it should be enough to add tags (see https://swagger.io/docs/specification/grouping-operations-with-tags/).
In swaggo you need to use #Tags declarative parameter in endpoint comment like this:
// #Tags: Books
See swaggo example code with #Tags here.
Related
Using RTK Query code generation I have a generated slice of my API from an OpenAPI spec. Following on from that example I have extended the generated slice as described by using generatedApi.enhanceEndpoints({/**/}).
Now I want to add prepareHeaders to the slice which is typically set via fetchBaseQuery, and per the docs my use case is for adding an auth token to each request. As the createApi function is called within the generated file I'd like to avoid touching this to include custom logic.
I think I'm looking for something like generatedApi.enhancePrepareHeaders({/**/}) which does not seem to exist yet.
How do I set headers for all requests when following the code splitting approach and without touching the generated file?
At the moment, that is only possible by writing a custom baseQuery function wrapping the original fetchBaseQuery.
From the next version of the code generator on, it will only create injectEndpoints calls and leave all the baseQuery configuration to a non-generated file.
I am using Spring JPA with mongo.I have a requirement to use contains query on one of the fields.If end users(UI/Service) hits the GET Request and looks for information in EMAIL Field,I need to search based on text.Pretty much it is like.
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/
This link explains that We can Use Contains to get the Data.
List<ScheduledNotification> findByMobileNumberContaining(String mobileNumber);
List<ScheduledNotification> findByEmailIdIgnoreCaseContaining(String emailId);
But when I am using this API,I am not able to get the data.So ,has any one done something like using Contains.
well ,I was not sending content type in header attribute in GET request.So yes it works,alright.There was no issue with method signature.
I'm using the django-rest-framework and django-rest-swagger to generate and display my API respectively. They're working beautifully. But...
I'd like to change the order that my models are being displayed in the Swagger schema view.
I have:
This order seems strange (not alphabetical, or based on any of my code I can find) but consistent (always the same) to me.
I would like (for example) the "phages" model to be first in the list.
How can I reorder these?
Django Rest Swagger will follow the order you insert the urls in your code.
For instance, something like:
# ...
url(r'^phages', include('phages.urls')),
url(r'^subclusters/', include('subclusters.urls')),
# ...
this will get phages at the top.
I am now using DRS for my simple django REST APIs and although its not perfect, it has been a great library so far. But having a few issues
I am using
django-rest-swagger==2.0.3
And my api-doc looks like this
Issue #1: I can't find a way to add some documentation, I tried putting YAML under my class based viewset action methods, not working. Put docstring under ViewSet class directly, no luck. Then I saw that in the latest DRS release, 2.0 change mentioned YAML docstring has been deprecated.
So how do I provide something like
1. Endpoint short description
2. parameter description and probably a sample format
Issue #2: How do I specify which parameter is mandatory.
For example, I have an action in my UserViewSet
#detail_route(methods=['post'], url_path='set-password')
#AssertInRequestBody(['password'])
def set_password(self, request, pk):
"""
set user password
"""
user = User.objects.get(pk=pk)
json_data = get_json_data(request)
user.set_password(json_data['password'])
user.save()
return DefaultResponse(_('Successfully set password for user %s'
% user.email), status.HTTP_200_OK)
And I want it to be a POST operation and there will be a password in the request body. I can't figure out a way to document that.
This applies to other operations, I guess right now DRS is simply looking at the model definition and serializer definition to determine which parameter is mandatory, which doesn't quite make sense to me.
I feel that DRS should provide some sort of decorators so that we can easily add corresponding documentation to an action method.
But maybe I am wrong, please help if DRS does provide such functionalities.
Thanks,
May be this is so late, but just for some help, this doc explains django rest swagger 2 integration step by step:
Django Rest Swagger 2 comprehensive documentation
Since you are doing a post, to add the end point short description this is what I would do
def set_password(self, request, pk):
"""
create:
set user password
"""
...
Or in your UserViewSet class:
class UserViewSet(...)
"""
set_password:
set user password
"""
That may answer question 1
I'm new to Stripe and I'd like generate a result that looks like the "Attributes" part of the Errors part : https://stripe.com/docs/api/curl#errors
It's looks like a table with two column, even though it's not a table.
I don't know how I can make this.
For information, I'm using Aglio to generate the template.
Cyril,
There is no easy way to do this in Markdown that I know of. You have two options:
Create your own layout template that manually adds this information, then tell aglio to use it.
Include some basic HTML in your API Blueprint. Here is an example. It just creates a definition list which describes the error attributes using the same CSS that already exists on the page to describe URI parameters.
You can use Markdown to create the tables of response types and codes, and if you want to use a three-column layout you can use the middle and right CSS classes.
Hope this helps!