Tool should allow for custom formats to be used and not give an error if they are

Issue #89 open
Craig Schwarzwald created an issue

Currently, if a format other than an OAS standard format is used anywhere in the swagger spec, this tool’s compare will throw an error of: Error: unknown format ”someCustomFormat” is used in schema at path ”somePropertyPath”.

Per the Swagger Documentation: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#Format

Under Data Types:
Primitives have an optional modifier property: format. OAS uses several known formats to define in fine detail the data type being used. However, to support documentation needs, the format property is an open string-valued property, and can have any value.

I believe the tool should be allowing these custom formats, and not throwing an error when they’re encountered in the specs. The following example should be valid:

{Swagger snippet}
  "definitions": {
    "someObject": {
       "properties": {
        "cost": {
          "type": "string"
          "format": "currency"
          "example": "$5.23"
        }
      }
    }
  }

Comments (9)

  1. Yousaf Nabi

    @{557057:526b7077-83d4-4cfb-955a-e261d129103c} Hey buddy, just come across this issue, and have a reproducible example here

    Are you actively working on this tool at the moment, I noticed you have some recent commits.

    Would love to help out

  2. Sebastian Tello Account Deactivated

    Hi @Yousaf Nabi , thanks, I see the specification of both Swagger 2 and OpenAPI 3 is clear about the format being an open string. IMO that’s not a good design (the same field having either a functional purpose or a documentation purpose), but we need to stick to their specification 🤷‍♂️ … I’ll try to get a fix in place soon

  3. Yousaf Nabi

    I have a fix in place now, well tested against unit tests, need to run it against the failing spec. just going to push against a fork now

  4. Log in to comment