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

Broken output after converting to workspace in vscode #5782

Open
erwinkramer opened this issue Nov 14, 2024 · 0 comments
Open

Broken output after converting to workspace in vscode #5782

erwinkramer opened this issue Nov 14, 2024 · 0 comments
Labels
Csharp Pull requests that update .net code status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@erwinkramer
Copy link

erwinkramer commented Nov 14, 2024

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

Csharp

Describe the bug

I had a lock file like this, generated by the CLI tool:

{
  "descriptionHash": "A8B3FF4FA538A2BB028EFB20C76C6CF203DF1A960CE76CF3AF6519312C4D211D046AE60754840416BF67F8B7AF6BEE0693E9628FB6C06139021D9CE60F82B1EB",
  "descriptionLocation": "../../../specs-downstream/github-api.json",
  "lockFileVersion": "1.0.0",
  "kiotaVersion": "1.20.0",
  "clientClassName": "GitHubClient",
  "typeAccessModifier": "Public",
  "clientNamespaceName": "DownstreamClients.GitHub",
  "language": "CSharp",
  "usesBackingStore": false,
  "excludeBackwardCompatible": false,
  "includeAdditionalData": true,
  "disableSSLValidation": false,
  "serializers": [
    "Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Text.TextSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Form.FormSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Multipart.MultipartSerializationWriterFactory"
  ],
  "deserializers": [
    "Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory",
    "Microsoft.Kiota.Serialization.Text.TextParseNodeFactory",
    "Microsoft.Kiota.Serialization.Form.FormParseNodeFactory"
  ],
  "structuredMimeTypes": [
    "application/json",
    "text/plain;q=0.9",
    "application/x-www-form-urlencoded;q=0.2",
    "multipart/form-data;q=0.1"
  ],
  "includePatterns": [
    "/repos/{owner}/{repo}/releases/*"
  ],
  "excludePatterns": [],
  "disabledValidationRules": []
}

Then i decided to remove the CLI tool and go with the VSCode extension. This resulted in the extention asking me if i want to convert to a workspace-based Kiota setup, fine, i press OK. This results into the following workspace:

{
  "version": "1.0.0",
  "clients": {
    "GitHubClient": {
      "language": "CSharp",
      "typeAccessModifier": "Public",
      "structuredMimeTypes": [
        "application/json",
        "text/plain;q=0.9",
        "application/x-www-form-urlencoded;q=0.2",
        "multipart/form-data;q=0.1"
      ],
      "clientNamespaceName": "DownstreamClients.GitHub",
      "usesBackingStore": false,
      "includeAdditionalData": true,
      "excludeBackwardCompatible": false,
      "disabledValidationRules": [],
      "descriptionLocation": "./specs-downstream/github-api.json",
      "includePatterns": [
        "/repos/{owner}/{repo}/releases/*"
      ],
      "excludePatterns": [],
      "outputPath": "./bank-api-minimal/DownstreamClients/GitHub"
    }
  },
  "plugins": {}
}

Now i re-generate the client-code by pressing "Re-generate" in the workspace.json.

At this point, my client differs, the following lines are removed in my client:

  ApiClientBuilder.RegisterDefaultSerializer<JsonSerializationWriterFactory>();
  ApiClientBuilder.RegisterDefaultSerializer<TextSerializationWriterFactory>();
  ApiClientBuilder.RegisterDefaultSerializer<FormSerializationWriterFactory>();
  ApiClientBuilder.RegisterDefaultSerializer<MultipartSerializationWriterFactory>();
  ApiClientBuilder.RegisterDefaultDeserializer<JsonParseNodeFactory>();
  ApiClientBuilder.RegisterDefaultDeserializer<TextParseNodeFactory>();
  ApiClientBuilder.RegisterDefaultDeserializer<FormParseNodeFactory>();

And results in the error at runtime (compiles just fine):

An exception of type 'System.InvalidOperationException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Content type application/json does not have a factory registered to be parsed'

which makes sense considering there was an addition (which Kiota decided it needed while using the CLI) in the lock file which didn't get ported over to the workspace:

 "serializers": [
    "Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Text.TextSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Form.FormSerializationWriterFactory",
    "Microsoft.Kiota.Serialization.Multipart.MultipartSerializationWriterFactory"
  ],
  "deserializers": [
    "Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory",
    "Microsoft.Kiota.Serialization.Text.TextParseNodeFactory",
    "Microsoft.Kiota.Serialization.Form.FormParseNodeFactory"
  ],

Expected behavior

Should be a working and smooth transition.

How to reproduce

Working setup is at https://github.com/erwinkramer/bank-api?tab=readme-ov-file#bank-api

Open API description file

No response

Kiota Version

1.20.0+81bdb1bf13383a749f794d47926d09733d2d7be1

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

  • OS Windows 11
  • x64

Debug output

No response

Other information

No response

@erwinkramer erwinkramer added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Nov 14, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Nov 14, 2024
@msgraph-bot msgraph-bot bot added the Csharp Pull requests that update .net code label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Csharp Pull requests that update .net code 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

1 participant