Skip to content

Commit

Permalink
Ref. VNG-Realisatie/gemma-zaken#130 -- mogelijke foutantwoorden in OAS
Browse files Browse the repository at this point in the history
Conform aan ZRC implementatie, neem de mogelijke foutantwoorden op in de
`openapi.yaml` spec.

Ook is dezelfde styling van foutpagina's overnomen uit het ZRC.
  • Loading branch information
sergei-maertens committed Aug 30, 2018
1 parent 63b8b54 commit 71f3f56
Show file tree
Hide file tree
Showing 13 changed files with 787 additions and 77 deletions.
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ django-filter
djangorestframework-camel-case
djangorestframework-filters
drf-yasg
zds-schema
zds-schema==0.0.30
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ six==1.11.0 # via drf-yasg, isodate, pip-tools, python-dateutil
unidecode==1.0.22 # via zds-schema
uritemplate==3.0.0 # via coreapi, drf-yasg
urllib3==1.23 # via requests
zds-schema==0.0.25
zds-schema==0.0.30
2 changes: 1 addition & 1 deletion requirements/jenkins.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ waitress==1.1.0 # via webtest
webob==1.8.2 # via webtest
webtest==2.0.30
wrapt==1.10.11 # via astroid
zds-schema==0.0.22
zds-schema==0.0.30
83 changes: 9 additions & 74 deletions src/drc/conf/api.py
Original file line number Diff line number Diff line change
@@ -1,76 +1,11 @@
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'djangorestframework_camel_case.render.CamelCaseJSONRenderer',
),
'DEFAULT_PARSER_CLASSES': (
'djangorestframework_camel_case.parser.CamelCaseJSONParser',
),
# 'DEFAULT_AUTHENTICATION_CLASSES': (
# 'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
# # 'rest_framework.authentication.SessionAuthentication',
# # 'rest_framework.authentication.BasicAuthentication'
# ),
# 'DEFAULT_PERMISSION_CLASSES': (
# 'oauth2_provider.contrib.rest_framework.TokenHasReadWriteScope',
# # 'rest_framework.permissions.IsAuthenticated',
# # 'rest_framework.permissions.AllowAny',
# ),
'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.URLPathVersioning',
#
# # Generic view behavior
# 'DEFAULT_PAGINATION_CLASS': 'ztc.api.utils.pagination.HALPagination',
'DEFAULT_FILTER_BACKENDS': (
'zds_schema.filters.Backend',
# 'rest_framework.filters.SearchFilter',
# 'rest_framework.filters.OrderingFilter',
),
#
# # Filtering
# 'SEARCH_PARAM': 'zoek', # 'search',
# 'ORDERING_PARAM': 'sorteer', # 'ordering',
#
# Versioning
'DEFAULT_VERSION': '1',
'ALLOWED_VERSIONS': ('1', ),
'VERSION_PARAM': 'version',
#
# # Exception handling
# 'EXCEPTION_HANDLER': 'ztc.api.utils.exceptions.exception_handler',
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
}
from zds_schema.conf.api import BASE_REST_FRAMEWORK, BASE_SWAGGER_SETTINGS

SWAGGER_SETTINGS = {
# 'SECURITY_DEFINITIONS': {
# 'OAuth2': {
# 'type': 'oauth2',
# 'flow': 'application',
# 'tokenUrl': '/oauth2/token/',
# 'scopes': {
# 'write': 'Schrijftoegang tot de catalogus en gerelateerde objecten.',
# 'read': 'Leestoegang tot de catalogus en gerelateerde objecten.'
# }
# },
# 'Bearer': {
# 'type': 'apiKey',
# 'name': 'Authorization',
# 'in': 'header'
# },
# },
'DEFAULT_AUTO_SCHEMA_CLASS': 'zds_schema.schema.AutoSchema',
REST_FRAMEWORK = BASE_REST_FRAMEWORK.copy()


SWAGGER_SETTINGS = BASE_SWAGGER_SETTINGS.copy()
SWAGGER_SETTINGS.update({
'DEFAULT_INFO': 'drc.api.schema.info',
'DEFAULT_FIELD_INSPECTORS': (
'drf_yasg.inspectors.CamelCaseJSONFilter',
'drf_yasg.inspectors.RecursiveFieldInspector',
'drf_yasg.inspectors.ReferencingSerializerInspector',
'drf_yasg.inspectors.ChoiceFieldInspector',
'drf_yasg.inspectors.FileFieldInspector',
'drf_yasg.inspectors.DictFieldInspector',
'drf_yasg.inspectors.HiddenFieldInspector',
'drf_yasg.inspectors.RelatedFieldInspector',
'drf_yasg.inspectors.SimpleFieldInspector',
'drf_yasg.inspectors.StringDefaultFieldInspector',
),
'DEFAULT_FILTER_INSPECTORS': (
'zds_schema.inspectors.query.FilterInspector',
)
}
# no geo things here
'DEFAULT_FIELD_INSPECTORS': BASE_SWAGGER_SETTINGS['DEFAULT_FIELD_INSPECTORS'][1:]
})
1 change: 1 addition & 0 deletions src/drc/sass/components/_all.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import "page-header/all";
@import "content/all";
@import "link-block/all";
@import "error-detail/all";
2 changes: 2 additions & 0 deletions src/drc/sass/components/error-detail/_all.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "error-detail";
@import "error-detail-properties";
22 changes: 22 additions & 0 deletions src/drc/sass/components/error-detail/_error-detail-properties.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.error-detail-properties {
display: flex;
flex-wrap: wrap;

&__property {
width: 20%;
min-width: 200px;
margin: 0;
padding: 10px 0;

font-weight: 700;
}

&__value {
width: 80%;
margin: 0;
padding: 10px 0;

font-weight: 700;
color: $color-code;
}
}
13 changes: 13 additions & 0 deletions src/drc/sass/components/error-detail/_error-detail.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '../../lib/responsive';

$error-detail-max-width: $breakpoint-laptop-l;

.error-detail {
max-width: $error-detail-max-width;
margin: 0 auto;

&__title {
color: $color-black;
border-bottom: solid 2px $color-vng-blue;
}
}
1 change: 1 addition & 0 deletions src/drc/sass/lib/_color.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ $color-white: #FFF;
$color-black: #041A34;

$color-vng-blue: #009FE3;
$color-code: #D14;
23 changes: 23 additions & 0 deletions src/drc/templates/zds_schema/error_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "master.html" %}
{% load staticfiles %}


{% block content %}
<article class="error-detail">

<h1 class="error-detail__title"><code>{{ type }}</code> fouttype</h1>

<dl class="error-detail-properties">
<dt class="error-detail-properties__property">HTTP Status code</dt>
<dd class="error-detail-properties__value"><code>{{ status_code }}</code></dd>

<dt class="error-detail-properties__property">Default title</dt>
<dd class="error-detail-properties__value"><code>{{ default_detail }}</code></dd>

<dt class="error-detail-properties__property">Default code</dt>
<dd class="error-detail-properties__value"><code>{{ default_code }}</code></dd>
</dl>


</article>
{% endblock %}
1 change: 1 addition & 0 deletions src/drc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# Simply show the index template.
path('', TemplateView.as_view(template_name='index.html')),
path('ref/', include('zds_schema.urls')),
]

# NOTE: The staticfiles_urlpatterns also discovers static files (ie. no need to run collectstatic). Both the static
Expand Down
Loading

0 comments on commit 71f3f56

Please sign in to comment.