Skip to content

No Request example with SerializeAsV2 #471

Closed

Description

@mattfrear

Swagger V2 supports examples on the request under /paths/[path]/[method]/parameters/[index]/schema/example
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#schemaExample

However, when rendering using SerializeAsV2, request examples are not output, as per the comments in https://github.com/microsoft/OpenAPI.NET/blob/master/src/Microsoft.OpenApi/Models/OpenApiExample.cs#L106

I think this is incorrect, and an example should be output when using SerializeAsV2.
Related issue: mattfrear/Swashbuckle.AspNetCore.Filters#115

Activity

  1. darrelmiller commented on Apr 26, 2020

    @darrelmiller
    Member

    Technically those are two different examples. One is an example of for the schema which is modelled as Any and the other is the example property of requestBody which is an OpenApiExample.

    If the example was set in the Schema object of the RequestBody.Content then it would render out in V2.

    I suppose in the V2 translation, we could reach into the first requestBody.Content object and pull the Example.Value into the Schema example. Somewhere here I think https://github.com/microsoft/OpenAPI.NET/blob/master/src/Microsoft.OpenApi/Models/OpenApiOperation.cs#L250

  2. added this to the 1.3 milestone on May 25, 2020
  3. mattfrear commented on Oct 26, 2020

    @mattfrear
    Author

    Hi Darrel

    I ended up working around this issue by setting the /definitions/[schemaType]/example object myself.

    If you want to Close this issue, that's cool.

  4. darrelmiller commented on Mar 14, 2021

    @darrelmiller
    Member

    Examples are going to change again in 3.1 so we will deal with this in the 3.1 release.

  5. modified the milestones: 1.3, 2.0 on Mar 14, 2021
  6. MaggieKimani1 commented on Mar 26, 2024

    @MaggieKimani1
    Contributor

    Fixed by #1538

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions