From 98081629a7dd031f98a63d44787dcc482b4c3a5c Mon Sep 17 00:00:00 2001 From: samwelkanda Date: Wed, 11 Sep 2024 16:54:00 +0300 Subject: [PATCH 1/3] Update CLI plugin add and edit commands with auth options --- output/sampleplugin-openapi.yml | 34 +++++++++++++++++++++++++++++++++ specs/cli/plugin-add.md | 9 +++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 output/sampleplugin-openapi.yml diff --git a/output/sampleplugin-openapi.yml b/output/sampleplugin-openapi.yml new file mode 100644 index 0000000000..533e6b454a --- /dev/null +++ b/output/sampleplugin-openapi.yml @@ -0,0 +1,34 @@ +openapi: 3.0.1 +info: + title: test - Subset + version: '1.0' +servers: + - url: http://localhost/ + description: There's no place like home +paths: + /test: + get: + summary: summary for test path + description: description for test path + operationId: test_get + responses: + '200': + description: test + '/test/{id}': + get: + summary: Summary for test path with id that is longer than 50 characters + description: description for test path with id + operationId: test_WithId + parameters: + - name: id + in: path + description: The id of the test + required: true + style: simple + schema: + type: integer + format: int32 + responses: + '200': + description: test +components: { } \ No newline at end of file diff --git a/specs/cli/plugin-add.md b/specs/cli/plugin-add.md index 9184d97b82..42125a7e33 100644 --- a/specs/cli/plugin-add.md +++ b/specs/cli/plugin-add.md @@ -86,6 +86,8 @@ For `apimanifest`, the generated file will be named `{plugin-name}-apimanifest.j | `--include-path \| -i` | No | /repos/{owner}/{repo} | A glob pattern to include paths from generation. Accepts multiple values. Defaults to no value which includes everything. | Yes, without its value | | `--exclude-path \| -e` | No | /advisories | A glob pattern to exclude paths from generation. Accepts multiple values. Defaults to no value which excludes nothing. | Yes, without its value | | `--type \| -t` | Yes | openai | The target type of plugin for the generated output files. Accepts multiple values. Possible values are `apiplugin`, `openai` and `apimanifest`.| Yes | +| `--authentication-type \| -at` | No | oauth2 | The authentication type that will be used to connect to the API. Accepts a single value corresponding to a supported OpenAPI security scheme. Possible values are `apikey`, `http`, `oauth2` and `openidconnect`.| | +| `--authentication-ref-id \| -refid` | No | xxxxxxxx | The authentication reference id that will be used to connect to the API. Accepts a single string value.| | | `--skip-generation \| --sg` | No | true | When specified, the generation would be skipped. Defaults to false. | Yes | | `--output \| -o` | No | ./generated/plugins/github | The output directory or file path for the generated output files. This is relative to the location of `workspace.json`. Defaults to `./output`. | Yes, without its value | @@ -95,7 +97,7 @@ For `apimanifest`, the generated file will be named `{plugin-name}-apimanifest.j ## Using `kiota plugin add` ```bash -kiota plugin add --plugins-name "GitHub" --openapi "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json" --include-path "/repos/{owner}/{repo}" --type apiplugin, apimanifest --output "./generated/plugins/github" +kiota plugin add --plugins-name "GitHub" --openapi "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json" --include-path "/repos/{owner}/{repo}" --type apiplugin, apimanifest --authentication-type "oauth2" --authentication-ref-id "somerefid" --output "./generated/plugins/github" ``` _The resulting `workspace.json` file will look like this:_ @@ -106,6 +108,8 @@ _The resulting `workspace.json` file will look like this:_ "clients": {...}, //if any "plugins": { "GitHub": { + "authType": "OAuthPluginVault", + "authReferenceId": "somerefid", "descriptionLocation": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json", "includePatterns": ["/repos/{owner}/{repo}"], "excludePatterns": [], @@ -150,7 +154,8 @@ _The resulting API Plugin named `github-apiplugin.json` will look like this:_ { "type": "OpenApi", "auth": { - "type": "None" + "type": "OAuthPluginVault", + "reference_id": "somerefid" }, "spec": { "url": "githubreposowner-openapi.yml" From 423cf3c53e451ef4b7934a739380aad9472c9ef3 Mon Sep 17 00:00:00 2001 From: samwelkanda Date: Wed, 11 Sep 2024 17:01:47 +0300 Subject: [PATCH 2/3] Update plugin edit --- output/sampleplugin-openapi.yml | 34 --------------------------------- specs/cli/plugin-edit.md | 7 ++++++- 2 files changed, 6 insertions(+), 35 deletions(-) delete mode 100644 output/sampleplugin-openapi.yml diff --git a/output/sampleplugin-openapi.yml b/output/sampleplugin-openapi.yml deleted file mode 100644 index 533e6b454a..0000000000 --- a/output/sampleplugin-openapi.yml +++ /dev/null @@ -1,34 +0,0 @@ -openapi: 3.0.1 -info: - title: test - Subset - version: '1.0' -servers: - - url: http://localhost/ - description: There's no place like home -paths: - /test: - get: - summary: summary for test path - description: description for test path - operationId: test_get - responses: - '200': - description: test - '/test/{id}': - get: - summary: Summary for test path with id that is longer than 50 characters - description: description for test path with id - operationId: test_WithId - parameters: - - name: id - in: path - description: The id of the test - required: true - style: simple - schema: - type: integer - format: int32 - responses: - '200': - description: test -components: { } \ No newline at end of file diff --git a/specs/cli/plugin-edit.md b/specs/cli/plugin-edit.md index aac51dbbb4..632ec68051 100644 --- a/specs/cli/plugin-edit.md +++ b/specs/cli/plugin-edit.md @@ -19,6 +19,8 @@ Once the `workspace.json` file and the API Manifest are updated, the code genera | `--include-path \| -i` | No | /repos/{owner}/{repo} | A glob pattern to include paths from generation. Accepts multiple values. Defaults to no value which includes everything. | Yes, without its value | | `--exclude-path \| -e` | No | /repos/{owner}/{repo}#DELETE | A glob pattern to exclude paths from generation. Accepts multiple values. Defaults to no value which excludes nothing. | Yes, without its value | | `--type \| -t` | Yes | openai | The target type of plugin for the generated output files. Accepts multiple values. Possible values are `apiplugin`, `openai` and `apimanifest`.| Yes | +| `--authentication-type \| -at` | No | oauth2 | The authentication type that will be used to connect to the API. Accepts a single value corresponding to a supported OpenAPI security scheme. Possible values are `apikey`, `http`, `oauth2` and `openidconnect`.| | +| `--authentication-ref-id \| -refid` | No | xxxxxxxx | The authentication reference id that will be used to connect to the API. Accepts a single string value.| | | `--skip-generation \| --sg` | No | true | When specified, the generation would be skipped. Defaults to false. | Yes | | `--output \| -o` | No | ./generated/plugins/github | The output directory or file path for the generated output files. This is relative to the current working directory. Defaults to `./output`. | Yes, without its value | @@ -39,6 +41,8 @@ _The resulting `workspace.json` file will look like this:_ "clients": {...}, //if any "plugins": { "GitHub": { + "authType": "OAuthPluginVault", + "authReferenceId": "somerefid", "descriptionLocation": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json", "includePatterns": ["/repos/{owner}/{repo}"], "excludePatterns": ["/repos/{owner}/{repo}#DELETE"], @@ -79,7 +83,8 @@ _The resulting API Plugin named `github-apiplugin.json` will look like this:_ { "type": "OpenApi", "auth": { - "type": "None" + "type": "OAuthPluginVault", + "reference_id": "somerefid" }, "spec": { "url": "githubreposowner-openapi.yml" From ae969901debb2b67c06fea22ea586cf67fa78322 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 10:10:34 -0400 Subject: [PATCH 3/3] Apply suggestions from code review --- specs/cli/plugin-add.md | 4 ++-- specs/cli/plugin-edit.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/specs/cli/plugin-add.md b/specs/cli/plugin-add.md index 42125a7e33..550a4490da 100644 --- a/specs/cli/plugin-add.md +++ b/specs/cli/plugin-add.md @@ -86,8 +86,8 @@ For `apimanifest`, the generated file will be named `{plugin-name}-apimanifest.j | `--include-path \| -i` | No | /repos/{owner}/{repo} | A glob pattern to include paths from generation. Accepts multiple values. Defaults to no value which includes everything. | Yes, without its value | | `--exclude-path \| -e` | No | /advisories | A glob pattern to exclude paths from generation. Accepts multiple values. Defaults to no value which excludes nothing. | Yes, without its value | | `--type \| -t` | Yes | openai | The target type of plugin for the generated output files. Accepts multiple values. Possible values are `apiplugin`, `openai` and `apimanifest`.| Yes | -| `--authentication-type \| -at` | No | oauth2 | The authentication type that will be used to connect to the API. Accepts a single value corresponding to a supported OpenAPI security scheme. Possible values are `apikey`, `http`, `oauth2` and `openidconnect`.| | -| `--authentication-ref-id \| -refid` | No | xxxxxxxx | The authentication reference id that will be used to connect to the API. Accepts a single string value.| | +| `--authentication-type \| --at` | No | oauth2 | The authentication type that will be used to connect to the API. Accepts a single value corresponding to a supported OpenAPI security scheme. Possible values are `apikey`, `http`, `oauth2` and `openidconnect`.| | +| `--authentication-ref-id \| --refid` | No | xxxxxxxx | The authentication reference id that will be used to connect to the API. Accepts a single string value.| | | `--skip-generation \| --sg` | No | true | When specified, the generation would be skipped. Defaults to false. | Yes | | `--output \| -o` | No | ./generated/plugins/github | The output directory or file path for the generated output files. This is relative to the location of `workspace.json`. Defaults to `./output`. | Yes, without its value | diff --git a/specs/cli/plugin-edit.md b/specs/cli/plugin-edit.md index 632ec68051..8ce2a880d7 100644 --- a/specs/cli/plugin-edit.md +++ b/specs/cli/plugin-edit.md @@ -19,8 +19,8 @@ Once the `workspace.json` file and the API Manifest are updated, the code genera | `--include-path \| -i` | No | /repos/{owner}/{repo} | A glob pattern to include paths from generation. Accepts multiple values. Defaults to no value which includes everything. | Yes, without its value | | `--exclude-path \| -e` | No | /repos/{owner}/{repo}#DELETE | A glob pattern to exclude paths from generation. Accepts multiple values. Defaults to no value which excludes nothing. | Yes, without its value | | `--type \| -t` | Yes | openai | The target type of plugin for the generated output files. Accepts multiple values. Possible values are `apiplugin`, `openai` and `apimanifest`.| Yes | -| `--authentication-type \| -at` | No | oauth2 | The authentication type that will be used to connect to the API. Accepts a single value corresponding to a supported OpenAPI security scheme. Possible values are `apikey`, `http`, `oauth2` and `openidconnect`.| | -| `--authentication-ref-id \| -refid` | No | xxxxxxxx | The authentication reference id that will be used to connect to the API. Accepts a single string value.| | +| `--authentication-type \| --at` | No | oauth2 | The authentication type that will be used to connect to the API. Accepts a single value corresponding to a supported OpenAPI security scheme. Possible values are `apikey`, `http`, `oauth2` and `openidconnect`.| | +| `--authentication-ref-id \| --refid` | No | xxxxxxxx | The authentication reference id that will be used to connect to the API. Accepts a single string value.| | | `--skip-generation \| --sg` | No | true | When specified, the generation would be skipped. Defaults to false. | Yes | | `--output \| -o` | No | ./generated/plugins/github | The output directory or file path for the generated output files. This is relative to the current working directory. Defaults to `./output`. | Yes, without its value |