Skip to content

Reader always set OpenApiParameter.Style  #1051

@richardkaspar

Description

@richardkaspar

Describe the bug
Microsoft.OpenApi.Readers 1.4.1 always gives the property Style of a parameter a value.
I think it is the default value. So the information is lost that 'style' was not set in the original file.
Microsoft.OpenApi.Readers 1.3.2 works as expected. OpenApiParameter.Style has the value null.

Eventually it is an effect of resolving the bug #858

To Reproduce
Use the following code to read 'readFile' and write 'writeFile'.
Open the two files in a compare tool.
Code:

using var stream = new FileStream(readFile, FileMode.Open);
var doc =
    new OpenApiStreamReader(
            new OpenApiReaderSettings
            {
                ReferenceResolution = ReferenceResolutionSetting.DoNotResolveReferences
            })
       .Read(stream, out _);

var sb = new StringBuilder();

var writer = new OpenApiYamlWriter(new StringWriter(sb, new CultureInfo("en_us")));

doc.SerializeAsV3(writer);

File.WriteAllText(writeFile, sb.ToString());

readFile:

openapi: 3.0.1
info:
  title: magic style
  version: 1.0.0
paths: 
  /foo:
    get:
      parameters:
        - name: id
          in: query
          schema:
            type: object
            additionalProperties:
              type: integer
      responses:
        '200':
          description: foo
          content:
            text/plain:
              schema:
                type: string

writeFile:

openapi: 3.0.1
info:
  title: magic style
  version: 1.0.0
paths:
  /foo:
    get:
      parameters:
        - name: id
          in: query
          style: form
          schema:
            type: object
            additionalProperties:
              type: integer
      responses:
        '200':
          description: foo
          content:
            text/plain:
              schema:
                type: string

Expected behavior

After reading the file, the value of OpenApiParameter.Style is null.

Maybe there exists a option to switch between the two behaviours.

Screenshots/Code Snippets
grafik

Additional context

Metadata

Metadata

Assignees

Labels

priority:p1High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions