From 4b86aa14ce7244026ad97ea8cdcd28a44526a637 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Wed, 8 Jun 2022 13:51:45 +0200 Subject: [PATCH 01/11] charts/nginz: Disbale zauth for /api-docs --- charts/nginz/templates/conf/_nginx.conf.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/nginz/templates/conf/_nginx.conf.tpl b/charts/nginz/templates/conf/_nginx.conf.tpl index 02c422b727..dc93efa895 100644 --- a/charts/nginz/templates/conf/_nginx.conf.tpl +++ b/charts/nginz/templates/conf/_nginx.conf.tpl @@ -352,6 +352,7 @@ http { # location /api-docs { + zauth off; default_type application/json; root {{ $.Values.nginx_conf.swagger_root }}; index resources.json; From 3670c9f97fa34a93ec4a2f83edf6b7d1a0629c9c Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Wed, 8 Jun 2022 14:23:44 +0200 Subject: [PATCH 02/11] charts/nginz: Serve swagger JSON --- .../swagger-resources-configmap.yaml | 31 +++++++++++++++++++ charts/nginz/values.yaml | 16 ++++++++++ 2 files changed, 47 insertions(+) create mode 100644 charts/nginz/templates/swagger-resources-configmap.yaml diff --git a/charts/nginz/templates/swagger-resources-configmap.yaml b/charts/nginz/templates/swagger-resources-configmap.yaml new file mode 100644 index 0000000000..0d47d2d5b3 --- /dev/null +++ b/charts/nginz/templates/swagger-resources-configmap.yaml @@ -0,0 +1,31 @@ +# Swagger-1.0 JSON to combine swagger-1.0 documents from different services +apiVersion: v1 +data: + reources.json: |2 + { + "apiVersion": "1.0", + "swaggerVersion": "1.2", + "apis": [ + { + "path": "/users", + "description": "Users, Connections and Onboarding" + }, + { + "path": "/push", + "description": "Push Notifications" + }, + { + "path": "/conversations", + "description": "Conversations and Messaging" + }, + { + "path": "/assets", + "description": "Assets" + } + ] + } + +kind: ConfigMap +metadata: + name: nginz-swagger + diff --git a/charts/nginz/values.yaml b/charts/nginz/values.yaml index 981bfdbb23..5cad1ab71c 100644 --- a/charts/nginz/values.yaml +++ b/charts/nginz/values.yaml @@ -100,6 +100,10 @@ nginx_conf: - all max_body_size: "0" disable_request_buffering: true + - path: /assets/api-docs$ + envs: + - staging + disable_zauth: true - path: /assets envs: - all @@ -123,6 +127,10 @@ nginx_conf: - all disable_zauth: true unlimited_requests_endpoint: true + - path: /users/api-docs$ + envs: + - staging + disable_zauth: true - path: /users envs: - all @@ -357,6 +365,10 @@ nginx_conf: disable_zauth: true envs: - all + - path: /conversations/api-docs$ + envs: + - staging + disable_zauth: true - path: /conversations/([^/]*)/otr/messages envs: - all @@ -463,6 +475,10 @@ nginx_conf: envs: - all gundeck: + - path: /push/api-docs$ + envs: + - staging + disable_zauth: true - path: /push envs: - all From d109606c787db3e0130d3c8e7ac8599f29409fd8 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Wed, 8 Jun 2022 15:19:38 +0200 Subject: [PATCH 03/11] charts/nginz: Serve swagger-ui --- charts/nginz/{conf/static => static/conf}/zauth.acl | 0 charts/nginz/templates/configmap.yaml | 2 +- charts/nginz/templates/deployment.yaml | 13 +++++++++++++ .../templates/swagger-resources-configmap.yaml | 2 +- charts/nginz/templates/swagger-ui-configmap.yaml | 8 ++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) rename charts/nginz/{conf/static => static/conf}/zauth.acl (100%) create mode 100644 charts/nginz/templates/swagger-ui-configmap.yaml diff --git a/charts/nginz/conf/static/zauth.acl b/charts/nginz/static/conf/zauth.acl similarity index 100% rename from charts/nginz/conf/static/zauth.acl rename to charts/nginz/static/conf/zauth.acl diff --git a/charts/nginz/templates/configmap.yaml b/charts/nginz/templates/configmap.yaml index cb57148817..1f3d0f97bd 100644 --- a/charts/nginz/templates/configmap.yaml +++ b/charts/nginz/templates/configmap.yaml @@ -10,7 +10,7 @@ data: {{- include "nginz_deeplink.json" . | indent 4 }} deeplink.html: |2 {{- include "nginz_deeplink.html" . | indent 4 }} -{{ (.Files.Glob "conf/static/*").AsConfig | indent 2 }} +{{ (.Files.Glob "static/conf/*").AsConfig | indent 2 }} kind: ConfigMap metadata: creationTimestamp: null diff --git a/charts/nginz/templates/deployment.yaml b/charts/nginz/templates/deployment.yaml index 3abda67744..9a42ef617b 100644 --- a/charts/nginz/templates/deployment.yaml +++ b/charts/nginz/templates/deployment.yaml @@ -25,6 +25,8 @@ spec: annotations: # An annotation of the configmap checksum ensures changes to the configmap cause a redeployment upon `helm upgrade` checksum/configmap: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum }} + checksum/swagger-ui-configmap: {{ include (print .Template.BasePath "/swagger-ui-configmap.yaml") . | sha256sum }} + checksum/swagger-resources-configmap: {{ include (print .Template.BasePath "/swagger-resources-configmap.yaml") . | sha256sum }} checksum/secret: {{ include (print .Template.BasePath "/secret.yaml") . | sha256sum }} fluentbit.io/parser-nginz: nginz spec: @@ -51,6 +53,11 @@ spec: - name: upstreams mountPath: /etc/wire/nginz/upstreams readOnly: true + - name: swagger-ui + mountPath: /opt/swagger-ui + readOnly: true + - name: swagger-resources + mountPath: {{ .Values.nginx_conf.swagger_root }} ports: - name: http containerPort: {{ .Values.config.http.httpPort }} @@ -81,3 +88,9 @@ spec: secretName: nginz - name: upstreams emptyDir: {} + - name: swagger-ui + configMap: + name: nginz-swagger-ui + - name: swagger-resources + configMap: + name: nginz-swagger-resources diff --git a/charts/nginz/templates/swagger-resources-configmap.yaml b/charts/nginz/templates/swagger-resources-configmap.yaml index 0d47d2d5b3..bbab49ce4d 100644 --- a/charts/nginz/templates/swagger-resources-configmap.yaml +++ b/charts/nginz/templates/swagger-resources-configmap.yaml @@ -27,5 +27,5 @@ data: kind: ConfigMap metadata: - name: nginz-swagger + name: nginz-swagger-resources diff --git a/charts/nginz/templates/swagger-ui-configmap.yaml b/charts/nginz/templates/swagger-ui-configmap.yaml new file mode 100644 index 0000000000..43891f52fe --- /dev/null +++ b/charts/nginz/templates/swagger-ui-configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +data: + zwagger-config.js: |2 +{{- include "nginz_zwagger-config.js" . | indent 4 }} +{{ (.Files.Glob "static/swagger-ui/*").AsConfig | indent 2 }} +kind: ConfigMap +metadata: + name: nginz-swagger-ui From 15d76329c754433703aee18c1a843ab2d48e49c4 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Wed, 8 Jun 2022 16:47:43 +0200 Subject: [PATCH 04/11] swagger -> zwagger --- charts/nginz/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nginz/templates/deployment.yaml b/charts/nginz/templates/deployment.yaml index 9a42ef617b..c33534c847 100644 --- a/charts/nginz/templates/deployment.yaml +++ b/charts/nginz/templates/deployment.yaml @@ -54,7 +54,7 @@ spec: mountPath: /etc/wire/nginz/upstreams readOnly: true - name: swagger-ui - mountPath: /opt/swagger-ui + mountPath: /opt/zwagger-ui readOnly: true - name: swagger-resources mountPath: {{ .Values.nginx_conf.swagger_root }} From ffdc62c5c383508fde641bf014efa21b73d5c656 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Wed, 8 Jun 2022 17:00:44 +0200 Subject: [PATCH 05/11] more typos --- charts/nginz/templates/swagger-resources-configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nginz/templates/swagger-resources-configmap.yaml b/charts/nginz/templates/swagger-resources-configmap.yaml index bbab49ce4d..f72c3b4304 100644 --- a/charts/nginz/templates/swagger-resources-configmap.yaml +++ b/charts/nginz/templates/swagger-resources-configmap.yaml @@ -1,7 +1,7 @@ # Swagger-1.0 JSON to combine swagger-1.0 documents from different services apiVersion: v1 data: - reources.json: |2 + resources.json: |2 { "apiVersion": "1.0", "swaggerVersion": "1.2", From 184cb6e117db47847a9d6aafb4359f2d43d8793a Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Wed, 8 Jun 2022 17:10:38 +0200 Subject: [PATCH 06/11] fiddly fix, at least serve JSON --- charts/nginz/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nginz/templates/deployment.yaml b/charts/nginz/templates/deployment.yaml index c33534c847..2454ea147c 100644 --- a/charts/nginz/templates/deployment.yaml +++ b/charts/nginz/templates/deployment.yaml @@ -57,7 +57,7 @@ spec: mountPath: /opt/zwagger-ui readOnly: true - name: swagger-resources - mountPath: {{ .Values.nginx_conf.swagger_root }} + mountPath: {{ .Values.nginx_conf.swagger_root }}/api-docs ports: - name: http containerPort: {{ .Values.config.http.httpPort }} From 2061c7fd1caaa21847671ba1fac49bc87be0a39d Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Tue, 14 Jun 2022 16:19:03 +0200 Subject: [PATCH 07/11] Remove /assets from swagger-ui as it has been migrated to swagger-2 --- charts/nginz/templates/swagger-resources-configmap.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/charts/nginz/templates/swagger-resources-configmap.yaml b/charts/nginz/templates/swagger-resources-configmap.yaml index f72c3b4304..a6b53022f6 100644 --- a/charts/nginz/templates/swagger-resources-configmap.yaml +++ b/charts/nginz/templates/swagger-resources-configmap.yaml @@ -17,10 +17,6 @@ data: { "path": "/conversations", "description": "Conversations and Messaging" - }, - { - "path": "/assets", - "description": "Assets" } ] } From 52cbd6269c8ef6dbee98b1589b1ebfe8fd73f186 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Tue, 14 Jun 2022 16:27:36 +0200 Subject: [PATCH 08/11] Add swagger-ui HTML which refers to swagger-ui JS/CSS from unpkg.com --- .gitignore | 1 + charts/nginz/static/swagger-ui/index.html | 77 ++++++++ charts/nginz/static/swagger-ui/tab.html | 221 ++++++++++++++++++++++ 3 files changed, 299 insertions(+) create mode 100644 charts/nginz/static/swagger-ui/index.html create mode 100644 charts/nginz/static/swagger-ui/tab.html diff --git a/.gitignore b/.gitignore index 5f5ac902c5..9e15d9491d 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ spar.integration-aws.yaml integration-aws.yaml DOCKER_ID* swagger-ui +!charts/nginz/static/swagger-ui deploy/services-demo/resources/templates/* deploy/services-demo/conf/nginz/zwagger-ui/* diff --git a/charts/nginz/static/swagger-ui/index.html b/charts/nginz/static/swagger-ui/index.html new file mode 100644 index 0000000000..3524029f07 --- /dev/null +++ b/charts/nginz/static/swagger-ui/index.html @@ -0,0 +1,77 @@ + + +
+ + + +
+ + + +
+ +
+ + + + + + + + + diff --git a/charts/nginz/static/swagger-ui/tab.html b/charts/nginz/static/swagger-ui/tab.html new file mode 100644 index 0000000000..0798782592 --- /dev/null +++ b/charts/nginz/static/swagger-ui/tab.html @@ -0,0 +1,221 @@ + + + + + + + Swagger UI + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +

+ +
+
+
+
+
+
+ +
+ +
+ +
+ +
+ + + +
 
+
+ + + From 2b714604c73772b7f27f0b79ebd2d893945863a9 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Tue, 14 Jun 2022 16:28:59 +0200 Subject: [PATCH 09/11] Delete /assets/api-docs as it doesn't exist --- charts/nginz/values.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/charts/nginz/values.yaml b/charts/nginz/values.yaml index 5cad1ab71c..e8aad9c07c 100644 --- a/charts/nginz/values.yaml +++ b/charts/nginz/values.yaml @@ -100,10 +100,6 @@ nginx_conf: - all max_body_size: "0" disable_request_buffering: true - - path: /assets/api-docs$ - envs: - - staging - disable_zauth: true - path: /assets envs: - all From d0706821ee653aa5e4e916618170b5b438359925 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Tue, 14 Jun 2022 16:32:08 +0200 Subject: [PATCH 10/11] Add changelog --- changelog.d/2-features/nginz-swagger-ui | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/2-features/nginz-swagger-ui diff --git a/changelog.d/2-features/nginz-swagger-ui b/changelog.d/2-features/nginz-swagger-ui new file mode 100644 index 0000000000..9a713df14e --- /dev/null +++ b/changelog.d/2-features/nginz-swagger-ui @@ -0,0 +1 @@ +charts/nginz: Serve swagger-ui for viewing swagger-1.2 docs \ No newline at end of file From 74728f7f935f617d7ed3129233a78ebf71d54008 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Tue, 14 Jun 2022 16:43:24 +0200 Subject: [PATCH 11/11] remove unnecessary zwagger-ui config --- charts/nginz/templates/conf/_zwagger-config.js.tpl | 3 --- charts/nginz/templates/configmap.yaml | 2 -- charts/nginz/templates/swagger-ui-configmap.yaml | 2 -- 3 files changed, 7 deletions(-) delete mode 100644 charts/nginz/templates/conf/_zwagger-config.js.tpl diff --git a/charts/nginz/templates/conf/_zwagger-config.js.tpl b/charts/nginz/templates/conf/_zwagger-config.js.tpl deleted file mode 100644 index ded11c8c5d..0000000000 --- a/charts/nginz/templates/conf/_zwagger-config.js.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{{ define "nginz_zwagger-config.js" }} -var environment = '{{ .Values.nginx_conf.env }}'; -{{- end }} diff --git a/charts/nginz/templates/configmap.yaml b/charts/nginz/templates/configmap.yaml index 1f3d0f97bd..0ddba4536b 100644 --- a/charts/nginz/templates/configmap.yaml +++ b/charts/nginz/templates/configmap.yaml @@ -4,8 +4,6 @@ data: {{- include "nginz_nginx.conf" . | indent 4 }} upstreams.txt: |2 {{- include "nginz_upstreams.txt" . | indent 4 }} - zwagger-config.js: |2 -{{- include "nginz_zwagger-config.js" . | indent 4 }} deeplink.json: |2 {{- include "nginz_deeplink.json" . | indent 4 }} deeplink.html: |2 diff --git a/charts/nginz/templates/swagger-ui-configmap.yaml b/charts/nginz/templates/swagger-ui-configmap.yaml index 43891f52fe..0ec5e5edc1 100644 --- a/charts/nginz/templates/swagger-ui-configmap.yaml +++ b/charts/nginz/templates/swagger-ui-configmap.yaml @@ -1,7 +1,5 @@ apiVersion: v1 data: - zwagger-config.js: |2 -{{- include "nginz_zwagger-config.js" . | indent 4 }} {{ (.Files.Glob "static/swagger-ui/*").AsConfig | indent 2 }} kind: ConfigMap metadata: