Skip to content

Commit

Permalink
Swagger-UI (PoC)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmsdev committed Jun 29, 2023
1 parent bffa645 commit 895d5bb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 26 deletions.
24 changes: 0 additions & 24 deletions Products/zms/plugins/www/swagger-ui/openapi.demo.yaml

This file was deleted.

1 change: 1 addition & 0 deletions Products/zms/zms.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class ZMS(
# Interface.
# ----------
swagger_ui = PageTemplateFile('zpt/ZMS/swagger-ui', globals()) # swagger-ui
openapi_yaml = PageTemplateFile('zpt/ZMS/openapi_yaml', globals()) # openapi.yaml
index_html = PageTemplateFile('zpt/ZMS/index', globals()) # index_html
f_index_html = PageTemplateFile('zpt/ZMS/index', globals()) # index_html
f_headDoctype = PageTemplateFile('zpt/ZMS/f_headdoctype', globals()) # Head.DOCTYPE
Expand Down
54 changes: 54 additions & 0 deletions Products/zms/zpt/ZMS/openapi_yaml.zpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<tal:block tal:define="
standard modules/Products.zms/standard;
dummy0 python:request.RESPONSE.setHeader('Content-Type','application/json');
">openapi: 3.0.0
info:
title: ZMS REST API
description: RESTful API for easy standardized access to the ZMS-universe.
version: 5.0.0
paths:
/++rest_api/{path}:
get:
summary: Returns a ZMS-object.
description: get ZMS-objects
parameters:
- name: path
in: path
description: id-path to resource
required: false
schema:
type: string
responses:
'200': # status code
description: A JSON array of user names
content:
application/json:
schema:
$ref: '#/components/responses/ZMSObjectResponse'
components:
responses:
ZMSObjectResponse:
content:
application/json:
schema:
oneOf:
<tal:block tal:repeat="metaObjId python:here.getMetaobjIds(sort=True)"><tal:block tal:define="metaObj python:here.getMetaobj(metaObjId); metaObjAttrIds python:here.getMetaobjAttrIds(metaObjId); objAttrs python:here.getObjAttrs(metaObjId); properties python:[x for x in metaObjAttrIds if x in objAttrs];"><tal:block tal:condition="properties">
- $ref: '#/components/schemas/<tal:block tal:content="metaObjId">The Name:</tal:block>'
</tal:block></tal:block></tal:block>
discriminator:
propertyName: meta_id
schemas:
<tal:block tal:repeat="metaObjId python:here.getMetaobjIds(sort=True)"><tal:block tal:define="metaObj python:here.getMetaobj(metaObjId); metaObjAttrIds python:here.getMetaobjAttrIds(metaObjId); objAttrs python:here.getObjAttrs(metaObjId); properties python:[x for x in metaObjAttrIds if x in objAttrs];"><tal:block tal:condition="properties">
<tal:block tal:content="metaObjId">The Name:</tal:block>:
type: object
required:
- meta_id
properties:
meta_id:
type: string
<tal:block tal:repeat="property properties">
<tal:block tal:content="property">The Property</tal:block>:
type: string
</tal:block>
</tal:block></tal:block></tal:block>
</tal:block>
4 changes: 2 additions & 2 deletions Products/zms/zpt/ZMS/swagger-ui.zpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<!-- `SwaggerUIBundle` is now available on the page -->
<script>
const ui = SwaggerUIBundle({
url: '/++resource++zms_/swagger-ui/openapi.demo.yaml',
url: './openapi_yaml',
"dom_id": "#swagger-ui",
"layout": "BaseLayout",
"deepLinking": true,
"showExtensions": true,
"showCommonExtensions": true,
"defaultModelsExpandDepth": -1,
"defaultModelsExpandDepth": 1,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
Expand Down

0 comments on commit 895d5bb

Please sign in to comment.