Grouping multiple controllers from same package in swagger - spring-boot

I am not able to find right way to group multiple apis in swagger.
Example:
1 have n number of Controllers.
let's say I have package
com.test.controller.feature1
com.test.controller.feature2
For both feature1 and feature2 I have x number of controllers.
Is there a way on the swagger-ui I can group these apis based on package so that swagger-ui is clutter free?
Here are the jars I am using for api documentation:
//springdoc-openapi
implementation 'org.springdoc:springdoc-openapi-ui:1.6.8'

Try with tags
#RestController
#RequestMapping("XXXX")
#Tag(name = "PACKAGE name1", description = "Group 1") {}
#RestController
#RequestMapping("YYYYY")
#Tag(name = "PACKAGE name1", description = "Group 1") {}
These will be one group.
Check this: https://swagger.io/docs/specification/grouping-operations-with-tags/

Related

Get the JPA filed name when we extended the metadata in olingo

Here it has been explained how can we extend metadata of an oData service in olingo V2.
<JPAEntityType name="SalesOrderHeader">
<EDMEntityType>SalesOrder</EDMEntityType>
<EDMEntitySet>SalesOrders</EDMEntitySet>
<JPAAttributes>
<JPAAttribute name="soId">ID</JPAAttribute>
<JPAAttribute name="netAmount">NetAmount</JPAAttribute>
<JPAAttribute name="buyerAddress">BuyerAddressInfo</JPAAttribute>
</JPAAttributes>
<JPARelationships>
<JPARelationship name="salesOrderItem">SalesOrderLineItemDetails</JPARelationship>
<JPARelationship name="notes">NotesDetails</JPARelationship>
</JPARelationships>
</JPAEntityType>
This small snippet of code explained how I can change a JPA entity field's name buyerAddress to the new name BuyerAddressInfo.
Now the question is how can I access to the original name when I have access to BuyerAddressInfo and ODataJPAContext?
I discovered following method from here. By this method I can access BuyerAddressInfo by having buyerAddress and JPA Entity name!
import org.apache.olingo.odata2.jpa.processor.api.access.JPAEdmMappingModelAccess;
import org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory;
// .....
JPAEdmMappingModelAccess jpaEdmMappingModelAccess =
ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAEdmMappingModelAccess(oDataJPAContext);
jpaEdmMappingModelAccess.loadMappingModel();
String newName = jpaEdmMappingModelAccess.mapJPAAttribute("SalesOrderHeader", "SalesOrderHeader"));
However what I am looking for is exactly vice versa! Therefore at the moment I use a Map and collect all the pairs and each time I iterate over them!

Django Rest Framework Documentation nested Serializer

I am using django rest framework documentation module to document my API.
I am facing a problem in the sense that nested serializers do not appear in my documentation, but only the outermost does.
As an example I have the following code:
class MyFirstSerializer(serializers.Serializer):
some_data = serializers.CharField(help_text="a number")
more_data = serializers.CharField(help_text="a letter")
class MySecondSerializer(serializers.Serializer):
email = serializers.EmailField(help_text="the email address")
number = serializers.CharField(help_text="a number")
another_serializer = MyFirstSerializer(help_text='a JSON structure')
The way the program works, is by having a nested JSON structure. However the documentation modules on mentions the fact that another_serializer is a field, and does not show what kind of data is supposed to be passed, somethinng like:
POST your/endpoint/
Parameter Description
email the email address
number a number
another_serializer a JSON structure
I would like a way for the documentation to be done recursively on all my field, in order to have a complete description of my endpoints, something like:
POST your/endpoint/
Parameter Description
email the email address
number a number
another_serializer
some_data a number
more_data a letter

Django rest framework field descriptions blank

In the Django rest framework, I'm creating a documentation page using the AutoSchema class. For selected API endpoints, I'm using manual_fields to add doc entries for various fields. These entries appear on the doc page as expected, in pretty tables, but the "Description" columns are blank, even though I'm including the description arg in the coreapi.Field() constructor. How do I get the descriptions to appear in the tables?
Here is an example field definition:
class FooList(APIView):
''' List the Foos
'''
schema = AutoSchema(
manual_fields=[
coreapi.Field(
name='format',
location='query',
description='The format in which to return results. One of: api, json',
required=False),
]
)
def get(request, format=None):
...
use coreschema module to describe field that api-shcema/ or api-docs/ will display correctly. example:
schema=coreschema.String(title='Format', description='The format in which to return results. One of: api, json'),
schema = AutoSchema(
manual_fields=[
coreapi.Field(
name='format',
location='query',
schema=coreschema.String(description='The format in which to return results. One of: api, json'),
required=False),
]
)

How can we retrieve/get the feature and scenario title in step definitions?

How can we retrieve/get feature, scenario title and tag name in step definitions?
For example I have a feature file booksearch with a feature:
Feature: Book Search
Scenario: Title should be matched
I perform a simple search on 'abc'
------------------------
------------------------
[When(#"I perform a simple search on '(.*)'")]
public void WhenIPerformASimpleSearchOn(string searchTerm)
{
--------
----------
//custom log
WriteLogs(int stepNum,string scenarioName,string tagname,string stepDescription,string stepResult)
}
How can we retrieve/get Feature and scenario title and tag name in step definitions for given scenario?
We are using MSTest as unit test provider.
You can retrieve the feature and scenario title by querying the FeatureInfo and ScenarioInfo classes.
For example, placing the following code in you step definition (i.e. WhenIPerformASimpleSearchOn() ):
var featureTitle = FeatureContext.Current.FeatureInfo.Title;
var featureTags = FeatureContext.Current.FeatureInfo.Tags;
var featureDescription = FeatureContext.Current.FeatureInfo.Description;
var scenarioTitle = ScenarioContext.Current.ScenarioInfo.Title;
var scenarioTags = ScenarioContext.Current.ScenarioInfo.Tags;
Will retrieve the feature title, tags and description as well as the scenario title and tags.
They are part of the context, you'll probably need to look at both the ScenarioContext and the
FeatureContext to get the details you want.

Django-nonrel sorting by foreignkey

Is there a way of returning items from a database in django-nonrel, using 'order_by' on a foreignkey?
Full details are as follows:
#Models.py
class Post(models.Model):
article = models.TextField(help_text='Paste or type HTML in here')
pub_date = models.DateField()
....
class TagItems(models.Model):
title = models.CharField(max_length=200)
....
class TagRel(models.Model):
the_post = models.ForeignKey('Post')
the_tag = models.ForeignKey('Tag')
TagRel defines a ManytoMany relationship between Post and TagItems classes.
I am wanting to get a list of articles for each tag.
#Desire output
My tag
-my first post
-my second post
My second tag
- my other post
- another post
All is good so far, as I use the following to filter the data:
def tagged_posts():
tag_items = TagItems.objects.all()
li =[]
for item in tag_items:
tag_rel_item = TagRel.objects.filter(the_tag__pk = item.pk)
li.append(tag_rel_item)
return {'list_of_objects': li}
I am using db-indexer to define the filter part of the query in db-indexes.py. All this works fine but I want to order my posts by publication dates.
Django docs tell me to use:
TagRel.objects.filter(the_tag__pk = item.pk).order_by('the_tag__pub_date')
But the order_by('the_tag__pub_date') part does not appear to be supported by django-nonrel.
The following also works in normal Django:
TagRel.objects.filter(the_tag__pk = item.pk).order_by('the_post')
This works because the Posts are already sorted by date in the model.
But this also does not appear to work in django-nonrel.
So my question is how do I return my posts ordered by date (latest>oldest)?
Thanks in advance
I'm taking a guess at this - you're using a ManyToManyField. I believe that's implemented using a ListProperty on App Engine's datastore.
See the section in the datastore documentation labeled "Properties With Multiple Values Can Have Surprising Behaviors":
http://code.google.com/appengine/docs/python/datastore/queries.html
That's most likely why your results appear unsorted. ManyToMany relations aren't supported natively in GAE. You'd probably have to sort them yourself after you get the results back.

Resources