Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

authType and authReferenceId gets override every time #5893

Open
maisarissi opened this issue Dec 10, 2024 · 2 comments
Open

authType and authReferenceId gets override every time #5893

maisarissi opened this issue Dec 10, 2024 · 2 comments
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@maisarissi
Copy link
Contributor

maisarissi commented Dec 10, 2024

Describe the bug

The authType and authReferenceId information are not take into consideration when building the plugin.

There are 3 scenarios where one can have these values populated:

  1. When the OpenAPI description has security scheme. More info here: If the security scheme is provided, Kiota should use it to create the right auth object #5070
  2. When one uses Kiota CLI to create their plugin and add the CLI switchers. More info here: Kiota CLI must include a way for one to provide authentication type and reference id when generating plugins #5072
  3. When one manually edit the workspace.json file.

When building the plugin, Kiota should always rely on the workspace.json information build the API plugin, rather than override the current information based on the OpenAPI description.

Expected behavior

When authType and authRefrenceId are provided, we should rely on them when building the plugin.
Their values should be used to build the runtimes object in the API plugin file.

Not null values

workspace.json example with key

{
  "version": "1.0.0",
  "clients": {},
  "plugins": {
    "GitHubv3RESTAPI": {
      "types": [
        "APIPlugin"
      ],
      "authType": "OAuthPluginVault",
      "authReferenceId": "NzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3IyMzZjU1ZGRjMC0zMTE5LTRkYTEtYjI0MC1jMDkyYjk0NzFjZTc=",
      "descriptionLocation": "https://raw.githubusercontent.com/APIs-guru/openapi-directory/gh-pages/v2/specs/github.com/1.1.4/openapi.json",
      "includePatterns": [
        "/search/commits",
        "/search/issues"
      ],
      "excludePatterns": [],
      "outputPath": "./appPackage"
    }
  }
}

API plugin example

{
    ...
    "runtimes": [
        {
            "type": "OpenApi",
            "auth": {
                "type": "OAuthPluginVault",
                "referenceId": "NzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3IyMzZjU1ZGRjMC0zMTE5LTRkYTEtYjI0MC1jMDkyYjk0NzFjZTc="
            },
            "spec": {
                "url": "githubv3restapi-openapi.yml"
            },
            "run_for_functions": [
                "search_issues_and_pull_requests",
                "search_repos"
            ]
        }
    ]
}

workspace.json example with variable

{
  "version": "1.0.0",
  "clients": {},
  "plugins": {
    "GitHubv3RESTAPI": {
      "types": [
        "APIPlugin"
      ],
      "authType": "OAuthPluginVault",
      "authReferenceId": "{{MYOAUTH2_CONFIGURATION_ID}}",
      "descriptionLocation": "https://raw.githubusercontent.com/APIs-guru/openapi-directory/gh-pages/v2/specs/github.com/1.1.4/openapi.json",
      "includePatterns": [
        "/search/commits",
        "/search/issues"
      ],
      "excludePatterns": [],
      "outputPath": "./appPackage"
    }
  }
}

API plugin example

{
    ...
    "runtimes": [
        {
            "type": "OpenApi",
            "auth": {
                "type": "OAuthPluginVault",
                "referenceId": "{{MYOUATH2_CONFIGURATION_ID}}"
            },
            "spec": {
                "url": "githubv3restapi-openapi.yml"
            },
            "run_for_functions": [
                "search_issues_and_pull_requests",
                "search_repos"
            ]
        }
    ]
}

Null values

workspace.json example

{
  "version": "1.0.0",
  "clients": {},
  "plugins": {
    "GitHubv3RESTAPI": {
      "types": [
        "APIPlugin"
      ],
      "authType": null,
      "authReferenceId": null,
      "descriptionLocation": "https://raw.githubusercontent.com/APIs-guru/openapi-directory/gh-pages/v2/specs/github.com/1.1.4/openapi.json",
      "includePatterns": [
        "/search/commits",
        "/search/issues"
      ],
      "excludePatterns": [],
      "outputPath": "./appPackage"
    }
  }
}

API Plugin example

{
    ...
    "runtimes": [
        {
            "type": "OpenApi",
            "auth": {
                "type": "None"
            },
            "spec": {
                "url": "githubv3restapi-openapi.yml"
            },
            "run_for_functions": [
                "search_issues_and_pull_requests",
                "search_repos"
            ]
        }
    ]
}

Kiota Version

1.21.1

@maisarissi maisarissi added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Dec 10, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Dec 10, 2024
@sebastienlevert
Copy link
Contributor

They are actually not taken into consideration when building the plugin. We need to be able to provide them to be able to regen without losing all the values TTK was able to get for us.

@maisarissi
Copy link
Contributor Author

I have updated the description to make the scenarios clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience
Projects
Status: Needs Triage 🔍
Development

No branches or pull requests

2 participants