Created
August 28, 2017 21:31
-
-
Save danizen/6f441f575d04258329d65ba25ec2ea74 to your computer and use it in GitHub Desktop.
Trying to achieve title in generated OpenAPI Schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import schemas | |
g = schemas.SchemaGenerator() | |
s = g.get_schema() | |
for f in s['adapter'].links['create'].fields: | |
print(f) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Adapter(models.Model): | |
universal_sequence = models.CharField(max_length=100) | |
index_sequence = models.CharField(verbose_name='Index Sequence', max_length=100) | |
full_sequence = models.CharField(max_length=100) | |
index_type = models.CharField(max_length=5, choices=IDX_CHOICES) | |
barcode = models.CharField(max_length=100, default='') | |
user = models.ForeignKey('User') | |
kit = models.ForeignKey('Kit', related_name='adapters') | |
def __str__(self): | |
return self.barcode | |
class Meta: | |
db_table = 'oadb_adaptor' | |
ordering = ('kit', 'barcode',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdapterSerializer(serializers.ModelSerializer): | |
barcode = serializers.CharField(label='Adapter Barcode') | |
class Meta: | |
model = Adapter | |
fields = ( | |
'id', 'barcode', 'universal_sequence', 'index_sequence', | |
'full_sequence', 'index_type', | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Field(name='barcode', required=True, location='form', schema=<coreschema.schemas.String object at 0x00000000075CF630>, description=None, type=None, example=None) | |
Field(name='universal_sequence', required=True, location='form', schema=<coreschema.schemas.String object at 0x00000000075CF7F0>, description=None, type=None, example=None) | |
Field(name='index_sequence', required=True, location='form', schema=<coreschema.schemas.String object at 0x00000000075CF8D0>, description=None, type=None, example=None) | |
Field(name='full_sequence', required=True, location='form', schema=<coreschema.schemas.String object at 0x00000000075CF908>, description=None, type=None, example=None) | |
Field(name='index_type', required=True, location='form', schema=<coreschema.schemas.Enum object at 0x00000000075CF898>, description=None, type=None, example=None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment