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

Invalid request headers generated for csharp client #4211

Closed
crobibero opened this issue Feb 21, 2024 · 1 comment · Fixed by #4218
Closed

Invalid request headers generated for csharp client #4211

crobibero opened this issue Feb 21, 2024 · 1 comment · Fixed by #4218
Assignees
Labels
Csharp Pull requests that update .net code help wanted Issue caused by core project dependency modules or library type:bug A broken experience WIP
Milestone

Comments

@crobibero
Copy link
Contributor

Command used:

dotnet kiota generate --openapi ./content-type-openapi.json -o Generated --language CSharp

dotnet kiota --version
1.11.1+86b3a623dc3fb6b55fed6a49519ec837f0fbc02c

With the following openapi spec:

{
    "openapi": "3.0.2",
    "info": {
        "title": "ContentType",
        "version": "1.0.0"
    },
    "paths": {
        "/test": {
            "post": {
                "requestBody": {
                  "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/test"
                            }
                        },
                        "application/json; profile=\"CamelCase\"": {
                            "schema": {
                                "$ref": "#/components/schemas/test"
                            }
                        },
                        "application/json; profile=\"PascalCase\"": {
                            "schema": {
                                "$ref": "#/components/schemas/test"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "response",
                        "content": {
                            "application/json": {
                                "schema": {
                                "$ref": "#/components/schemas/test"
                                }
                            },
                            "application/json; profile=\"CamelCase\"": {
                                "schema": {
                                "$ref": "#/components/schemas/test"
                                }
                            },
                            "application/json; profile=\"PascalCase\"": {
                                "schema": {
                                "$ref": "#/components/schemas/test"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
          "test":  {
            "type": "object",
            "properties": {
              "prop1": {
                "type": "integer",
                "format": "int32"
              }
            }
          }
        }
    }
}

The following line is generated:

requestInfo.Headers.TryAdd("Accept", "application/json, application/json;profile="CamelCase", application/json;profile="PascalCase"");

where it should be:

requestInfo.Headers.TryAdd("Accept", "application/json, application/json;profile=\"CamelCase\", application/json;profile=\"PascalCase\"");
@andrueastman
Copy link
Member

Thanks for raising this @crobibero

Any chance you'd be willing to submit a PR to sanitize the generation of the parameter? I believe the fix would need to be applied at

writer.WriteLine($"{RequestInfoVarName}.Headers.TryAdd(\"Accept\", \"{codeElement.AcceptHeaderValue}\");");

@andrueastman andrueastman added type:bug A broken experience Csharp Pull requests that update .net code labels Feb 22, 2024
@baywet baywet added this to the Backlog milestone Feb 22, 2024
@baywet baywet added the help wanted Issue caused by core project dependency modules or library label Feb 22, 2024
@baywet baywet modified the milestones: Backlog, Kiota v1.12 Feb 22, 2024
@baywet baywet moved this from Todo to In Progress in Kiota Feb 22, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Kiota Feb 22, 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 help wanted Issue caused by core project dependency modules or library type:bug A broken experience WIP
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants