From 521819c3c9a7c587f63cde0ce2afe70ddcbdc5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 28 Apr 2023 07:10:16 +0900 Subject: [PATCH] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- README.md | 46 +++++++++++++++++++++++++++++++++++++++- src/config/variable.json | 10 ++++----- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c7d1443..30700a2 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,52 @@ Note that the license also inherits to the output. ### About build -- `src/openapi/**/*.yaml#/paths/*/get/parameters` will be overwritten by `src/config/parameters.yaml#/paths/~1parameters/get/parameters` +- `src/openapi/**/*.yaml#/paths/*/*/parameters` will be overwritten by `src/config/parameters.yaml#/paths/~1parameters/*/parameters` + - This overwritten done before parsing yaml +- `src/openapi/**/*.yaml#/paths/*/*/requestBody` will be overwritten by `src/config/parameters.yaml#/paths/~1parameters/*/requestBody` + - This overwritten done before parsing yaml - `src/openapi/**/*.yaml#/paths/*/get/responses/200/headers` will be overwritten by `src/config/headers.yaml#/components/headers` + - This overwritten done before parsing yaml +- Items enclosed in double brackets are placeholders + - `src/config/placeholder.json` replaces it + - If a placeholder is used in `src/config/**/*.yaml`, the pathname is added as a prefix + - This substitution is done before parsing the yaml + +#### variable.json + +It can be written as `{% if variable == value %}` `{ endif }` + +| lang | description| +|---|---| +| docs | Outputs the most correct swagger syntax | +| typescript | Since it is difficult to handle default values with the typescript generator, we refer to `src/config/placeholder.json` and handle default values | +| dart | Basically the same as typescript, but headers are processed as parameters | + +##### *_parameters = string + +- This is defined in `src/config/parameters.yaml` +- Replace `src/config/placeholder.json` as an string + +##### *_parameters = object + +- This is defined in `src/config/parameters.yaml` +- Replace `src/config/placeholder.json` as an object + +##### *_parameters = schema_content + +- The schema automatically generated from the `src/config/placeholder.json` is replaced with `src/openapi/**/*.yaml#/paths/*/*/parameters` +- Some generators cannot handle it correctly because it generates the syntax introduced in swagger 3.0 +- This is defined in `tools/build.py` + +##### *_parameters = schema_parameters + +- The schema automatically generated from the `src/config/placeholder.json` is replaced with `src/openapi/**/*.yaml#/paths/*/*/parameters` + +##### *_parameters = schema_request_body + +- The schema automatically generated from the `src/config/placeholder.json` is replaced with `src/openapi/**/*.yaml#/paths/*/*/requestBody` + +#### command ```shell python -V # Python 3.10.8 diff --git a/src/config/variable.json b/src/config/variable.json index 799997e..38fc366 100644 --- a/src/config/variable.json +++ b/src/config/variable.json @@ -1,4 +1,9 @@ { + "docs": { + "header": "securitySchemes", + "get_parameters": "schema_content", + "post_parameters": "schema_parameters" + }, "dart": { "header": "parameters", "get_parameters": "string", @@ -13,10 +18,5 @@ "header": "securitySchemes", "get_parameters": "string", "post_parameters": "string" - }, - "docs": { - "header": "securitySchemes", - "get_parameters": "schema_content", - "post_parameters": "schema_content" } } \ No newline at end of file