Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sample values for string formats uuid, hostname, ipv4 and ipv6 #5033

Merged
merged 1 commit into from
Nov 16, 2018
Merged

Add sample values for string formats uuid, hostname, ipv4 and ipv6 #5033

merged 1 commit into from
Nov 16, 2018

Conversation

hkosova
Copy link
Contributor

@hkosova hkosova commented Nov 16, 2018

Description

This PR adds sample values for type: string with format: uuid, format: hostname, format: ipv4 and format: ipv6. While these formats are not defined by the OpenAPI Specification, they are defined by the JSON Schema which is what OpenAPI's Schema Object is closely based on.

      type: object
      properties:
        id:
          type: string
          format: uuid
        hostname:
          type: string
          format: hostname
        ipv4:
          type: string
          format: ipv4
        ipv6:
          type: string
          format: ipv6

will now produce

{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "hostname": "example.com",
  "ipv4": "198.51.100.42",
  "ipv6": "2001:0db8:5b96:0000:0000:426f:8e17:642a"
}

Motivation and Context

As a technical writer, I want Swagger UI to display meaningful examples even if the API definition does not include example values.

Also fixes #4986.

How Has This Been Tested?

Tested manually, also added automated tests.

Screenshots

Swagger UI: examples for uuid, hostname, ipv4 and ipv6

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.

@shockey shockey merged commit 89868a8 into swagger-api:master Nov 16, 2018
@shockey
Copy link
Contributor

shockey commented Nov 16, 2018

thanks @hkosova! 💪

@mfrischbutter
Copy link

thanks, is working well!

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.

Support for property types ipv4, ipv6 and date-time in example values
3 participants