Tool should allow for custom formats to be used and not give an error if they are
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)
-
-
There are several first class supported
formats
supported by OAS spechttps://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#data-types
I believe from reading the spec, that
type
must be present, butformat
is optional can be one of the below supported, or any string value.
-
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
-
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
-
agreed it is a bit gnarly
-
Account Deactivated - changed status to resolved
-
Account Deactivated -
Account Deactivated Hmm it’s annoying that just by raising the PR, it marks the issue as resolved before it has been merged.
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
@Yousaf Nabi I just say that.. I’ve implemented a fix here: https://bitbucket.org/atlassian/swagger-mock-validator/pull-requests/40 , let me know what you think
-
Account Deactivated - changed status to open
waiting for https://bitbucket.org/atlassian/swagger-mock-validator/pull-requests/40 to be merged
- Log in to comment
@{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