parent
5c2c39c82d
commit
3377ef08ea
|
|
@ -77,9 +77,11 @@ class InlineSerializerInspector(SerializerInspector):
|
||||||
|
|
||||||
if isinstance(field, (serializers.ListSerializer, serializers.ListField)):
|
if isinstance(field, (serializers.ListSerializer, serializers.ListField)):
|
||||||
child_schema = self.probe_field_inspectors(field.child, ChildSwaggerType, use_references)
|
child_schema = self.probe_field_inspectors(field.child, ChildSwaggerType, use_references)
|
||||||
|
limits = find_limits(field) or {}
|
||||||
return SwaggerType(
|
return SwaggerType(
|
||||||
type=openapi.TYPE_ARRAY,
|
type=openapi.TYPE_ARRAY,
|
||||||
items=child_schema,
|
items=child_schema,
|
||||||
|
**limits
|
||||||
)
|
)
|
||||||
elif isinstance(field, serializers.Serializer):
|
elif isinstance(field, serializers.Serializer):
|
||||||
if swagger_object_type != openapi.Schema:
|
if swagger_object_type != openapi.Schema:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ from decimal import Decimal
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.compat import MinValueValidator
|
from rest_framework.compat import MinValueValidator, MaxLengthValidator
|
||||||
|
|
||||||
from snippets.models import LANGUAGE_CHOICES, STYLE_CHOICES, Snippet
|
from snippets.models import LANGUAGE_CHOICES, STYLE_CHOICES, Snippet
|
||||||
|
|
||||||
|
|
@ -65,11 +65,13 @@ class SnippetSerializer(serializers.Serializer):
|
||||||
)
|
)
|
||||||
title = serializers.CharField(required=False, allow_blank=True, max_length=100)
|
title = serializers.CharField(required=False, allow_blank=True, max_length=100)
|
||||||
code = serializers.CharField(style={'base_template': 'textarea.html'})
|
code = serializers.CharField(style={'base_template': 'textarea.html'})
|
||||||
|
tags = serializers.ListField(child=serializers.CharField(min_length=2), min_length=3, max_length=15)
|
||||||
linenos = serializers.BooleanField(required=False)
|
linenos = serializers.BooleanField(required=False)
|
||||||
language = LanguageSerializer(help_text="Sample help text for language")
|
language = LanguageSerializer(help_text="Sample help text for language")
|
||||||
styles = serializers.MultipleChoiceField(choices=STYLE_CHOICES, default=['friendly'])
|
styles = serializers.MultipleChoiceField(choices=STYLE_CHOICES, default=['friendly'])
|
||||||
lines = serializers.ListField(child=serializers.IntegerField(), allow_empty=True, allow_null=True, required=False)
|
lines = serializers.ListField(child=serializers.IntegerField(), allow_empty=True, allow_null=True, required=False)
|
||||||
example_projects = serializers.ListSerializer(child=ExampleProjectSerializer(), read_only=True)
|
example_projects = serializers.ListSerializer(child=ExampleProjectSerializer(), read_only=True,
|
||||||
|
validators=[MaxLengthValidator(100)])
|
||||||
difficulty_factor = serializers.FloatField(help_text="this is here just to test FloatField",
|
difficulty_factor = serializers.FloatField(help_text="this is here just to test FloatField",
|
||||||
read_only=True, default=lambda: 6.9)
|
read_only=True, default=lambda: 6.9)
|
||||||
rate_as_string = serializers.DecimalField(max_digits=6, decimal_places=3, default=Decimal('0.0'),
|
rate_as_string = serializers.DecimalField(max_digits=6, decimal_places=3, default=Decimal('0.0'),
|
||||||
|
|
|
||||||
|
|
@ -1023,6 +1023,7 @@ definitions:
|
||||||
Snippet:
|
Snippet:
|
||||||
required:
|
required:
|
||||||
- code
|
- code
|
||||||
|
- tags
|
||||||
- language
|
- language
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|
@ -1057,6 +1058,13 @@ definitions:
|
||||||
title: Code
|
title: Code
|
||||||
type: string
|
type: string
|
||||||
minLength: 1
|
minLength: 1
|
||||||
|
tags:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
minLength: 2
|
||||||
|
maxItems: 15
|
||||||
|
minItems: 3
|
||||||
linenos:
|
linenos:
|
||||||
title: Linenos
|
title: Linenos
|
||||||
type: boolean
|
type: boolean
|
||||||
|
|
@ -1553,6 +1561,7 @@ definitions:
|
||||||
items:
|
items:
|
||||||
$ref: '#/definitions/Project'
|
$ref: '#/definitions/Project'
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
maxItems: 100
|
||||||
difficultyFactor:
|
difficultyFactor:
|
||||||
title: Difficulty factor
|
title: Difficulty factor
|
||||||
description: this is here just to test FloatField
|
description: this is here just to test FloatField
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue