Skip to content

Updating OpenApiOperation body parameter name break original request body content type. #5317

@plehegarat

Description

@plehegarat

Describe the bug

When updating OpenApiOperation body Parameter Name,
original Request body content type changed.

Version of NSwag toolchain, computer and .NET runtime used

Reproduced on last version.

To Reproduce

Take an multipart/form-data content body schema :

"requestBody": {
"content": {
"multipart/form-data": {
}
}
}

When manipulating body parameter's Name (don't know if only this property concerned)
Schema content type change to "application/json"

Simple sample :

    OpenApiDocument document = ...;

    document.Operations
        .SelectMany(op => op.Operation.Parameters)
        .ForEach(p=>
        {
            p.Name = "new Name";
        });

Result is :

"requestBody": {
"x-name": "new Name",
"content": {
"application/json": {
}
}
}

Expected behavior

Expected keeping content type or refuse updating / throw exception as manipulation is considered as a nonsense or not allowed this way.
/!\ Notice than when using Operation.RequestBody instead of parameter entry the behavior doesn't exists.

Hope this will help progressing of this wonderfull tool that is nswag.
Best regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions