Skip to content

Examples are missing after converting V3 swagger to V2 #1430

Closed

Description

@TinaLiu02

Bug:
we need to convert V3 swagger to V2 and transform the examples, but examples part in request/responses/components are missing after converting V3 swagger to V2.
v3 swagger file: https://github.com/linkedin-developers/job-posting-development-tools/blob/master/OpenAPI-specification/job_posting_v2.yaml

To Reproduce
Steps to reproduce the current behavior:

  1. run project Microsoft.OpenApi.Workbench
  2. copy the content of v3 swagger file and paste it to "input content" area
  3. choose JSON for Format, choose V2.0 for Version and click button "Convert"

Expected behavior
examples should display in V2 swagger.

Screenshots/Code Snippets
stack trace:

Microsoft.OpenApi.dll!Microsoft.OpenApi.Models.OpenApiDocument.SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) Line 143 C#
Microsoft.OpenApi.dll!Microsoft.OpenApi.Extensions.OpenApiSerializableExtensions.Serialize<Microsoft.OpenApi.Models.OpenApiDocument>(Microsoft.OpenApi.Models.OpenApiDocument element, Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) Line 125 C#
Microsoft.OpenApi.dll!Microsoft.OpenApi.Extensions.OpenApiSerializableExtensions.Serialize<Microsoft.OpenApi.Models.OpenApiDocument>(Microsoft.OpenApi.Models.OpenApiDocument element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion, Microsoft.OpenApi.OpenApiFormat format, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings) Line 94 C#
Microsoft.OpenApi.Workbench.dll!Microsoft.OpenApi.Workbench.MainModel.WriteContents(Microsoft.OpenApi.Models.OpenApiDocument document) Line 312 C#
Microsoft.OpenApi.Workbench.dll!Microsoft.OpenApi.Workbench.MainModel.ParseDocument() Line 279 C#
Microsoft.OpenApi.Workbench.dll!Microsoft.OpenApi.Workbench.MainWindow.Button_Click(object sender, System.Windows.RoutedEventArgs e) Line 26 C#

screenshot:
image

image

Activity

  1. darrelmiller commented on Oct 20, 2023

    @darrelmiller
    Member

    Unfortunately there is no support for multiple examples for body parameters in OpenAPI v2. We could carry the examples though to the V2 document as an extension. e.g. x-examples Would that address your need?

  2. TinaLiu02 commented on Oct 23, 2023

    @TinaLiu02
    ContributorAuthor

    yes. that would be great.

  3. darrelmiller commented on Nov 28, 2023

    @darrelmiller
    Member

    We need to add serializing of the examples map to x-examples here

    if (Content.Values.Any(m => m.Example != null))

  4. darrelmiller commented on Jan 18, 2024

    @darrelmiller
    Member

    Maggie Kimani (@MaggieKimani1) Why is this a breaking change? Could this not be implemented in the current V1.x branch?

  5. MaggieKimani1 commented on Jan 23, 2024

    @MaggieKimani1
    Contributor

    Maggie Kimani (@MaggieKimani1) Why is this a breaking change? Could this not be implemented in the current V1.x branch?

    You're right, this isn't a breaking change. I have rebased the branch onto vnext so that this goes out with the next v1.x release.

  6. RachitMalik12 commented on Feb 27, 2025

    @RachitMalik12
    Contributor

    Completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions