genericparser seed code
[modeling/etsicatalog.git] / genericparser / packages / serializers / problem_details.py
1 # Copyright 2018 ZTE Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from rest_framework import serializers
16
17
18 class ProblemDetailsSerializer(serializers.Serializer):
19     type = serializers.CharField(
20         help_text='A URI reference according to IETF RFC 3986 [10] that identifies the problem type. \
21         It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. \
22         When this member is not present, its value is assumed to be "about:blank".',
23         required=False,
24         allow_null=True,
25         allow_blank=True
26     )
27     title = serializers.CharField(
28         help_text='A short, human-readable summary of the problem type. \
29         It should not change from occurrence to occurrence of the problem, except for purposes of localization. \
30         If type is given and other than "about:blank", this attribute shall also be provided.',
31         required=False,
32         allow_null=True,
33         allow_blank=True
34     )
35     title = serializers.IntegerField(
36         help_text='The HTTP status code for this occurrence of the problem.',
37         required=True,
38         allow_null=False
39     )
40     detail = serializers.CharField(
41         help_text='A human-readable explanation specific to this occurrence of the problem.',
42         required=True,
43         allow_null=False,
44         allow_blank=False
45     )
46     instance = serializers.CharField(
47         help_text='A URI reference that identifies the specific occurrence of the problem. \
48         It may yield further information if dereferenced.',
49         required=False,
50         allow_null=True,
51         allow_blank=True
52     )
53     additional_attributes = serializers.DictField(
54         help_text='Any number of additional attributes, as defined in a specification or by an implementation.',
55         child=serializers.CharField(help_text='Additional attribute', allow_blank=True),
56         required=False,
57         allow_null=True,
58     )