Skip to content

Conversation

@mathis-m
Copy link
Contributor

@mathis-m mathis-m commented Jan 12, 2021

Description

The sample gen should, in case of json media type and string literal example, try to parse the example. If it can not parse the example like the xml example shown in issue(for media type json) it will return it like it is a json string example.
In case it is parable it will return the json. This will result in rendering the json string literal examples as expected.

Motivation and Context

Fixes #6595

How Has This Been Tested?

Have taken care to ensure that literals are generated as json.

Screenshots (if appropriate):

https://editor.swagger.io/?url=https://gist.githubusercontent.com/mathis-m/20bf8fb2deabd2a5a0821418aa4adacc/raw/df18fb826d8fac8a648250dfa4e9050672992cbf/Zs2qqBv9YU.txt

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

@mathis-m mathis-m marked this pull request as draft January 12, 2021 20:52
@mathis-m mathis-m force-pushed the bug/6595 branch 2 times, most recently from 1eba697 to 7ec35ca Compare January 12, 2021 21:06
@mathis-m mathis-m marked this pull request as ready for review January 14, 2021 18:03
@tim-lai tim-lai merged commit a2f7917 into swagger-api:master Jan 14, 2021
@tim-lai
Copy link
Contributor

tim-lai commented Jan 14, 2021

@mathis-m PR merged! Thanks for another contribution!

@smagafurov
Copy link

This merge breaks the schema:

openapi: 3.0.0
info:
  title: Probe
  version: 1.0.0
servers: []
components:
  schemas:
    Probe:
      type: object
      properties:
        probe:
          type: string
          example: '1.0'
paths:
  /api/v1/probe:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Probe'
      responses:
        '200':
          description: success response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Probe'

"Example Value" incorrectly shown as:

{
  "probe": 1
}

Correctly expected as:

{
  "probe": "1.0"
}

@mathis-m
Copy link
Contributor Author

mathis-m commented Jan 27, 2021

#6872 may fix this

Fixes #6827:

https://gist.githubusercontent.com/mathis-m/6ccf292b5560fc09f50e52f2ad0f1e23/raw/f8b16efb750879d279e1c1fb3fffdb521b6dcad0/rxx6ldSupt.txt
image
Originally posted by @smagafurov in #6827 (comment)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Response examples line break not working

3 participants