Skip to content

Examples containing date-time strings are not quoted in YAML output #95

@frangipanes

Description

@frangipanes

Describe the bug
When I create a io.swagger.v3.oas.annotations.media.Content example with a date-time property, such as

Content(
    mediaType = MediaType.APPLICATION_JSON,
    examples = [ExampleObject(value = """{"refreshAt": "2022-03-03T12:12:16Z"}""")],
    schema = Schema(implementation = KeyUpdateCommandsResponse::class),
)

the plugin generates the following yaml output:

content:
  application/json:
    example:
      refreshAt: 2022-03-03T12:12:16Z

note that the refreshAt property is not escaped with quotation marks.

When I copy the generated yaml into the Swagger Editor, the example is rendered as:

"refreshAt": OrderedMap {}

which is incorrect.

The generated json format has the correct behaviour (but then again, it puts everything in double quotes, so to be expected).

To Reproduce
See above.

Expected behavior
the plugin generates the following yaml:

content:
  application/json:
    example:
      refreshAt: "2022-03-03T12:12:16Z"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions