OpenAPITools / openapi-style-validator

A customizable style validator to make sure your OpenAPI spec follows your organization's standards.
https://openapitools.github.io/openapi-style-validator/
Apache License 2.0
197 stars 43 forks source link

Data Type Format validation #139

Open baurceanu opened 3 years ago

baurceanu commented 3 years ago

Hi, it might be an option to add validation of data type format. Use case: Date time format validation. On my current project we use custom formats (not ISO / RFC). So I'd like to have something like this in configuration:

<configuration>
    <validateDataTypeFormat>true</validateDataTypeFormat>
    <customDataTypeFormats>
        <customDataTypeFormat>my-date-time</customDataTypeFormat> 
    </customDataTypeFormats>
    <forbiddenDataTypeFormats>
        <forbiddenDataTypeFormat>date-time<forbiddenDataTypeFormat>
    </forbiddenDataTypeFormats>
</configuration>

By default all standard OAS formats are allowed and all custom formats are forbidden.

Valid schema:

User:
  type: object
  properties:
    birthDateTime:
      type: string
      format: my-date-time

Not valid schema:

User:
  type: object
  properties:
    birthDateTime:
      type: string
      format: date-time
JFCote commented 3 years ago

Hi @baurchanu ,

Thanks for the suggestion. I'll look into it in 2021. For the moment, the configuration of openapi-style-validator is very simple, with only 9 boolean flags and we want to keep it that way but like you said, the default could be like it is today and we could add more options for situations like that.

By the way, if you have time to create a PR for this, I will take the time to review it and merge it if everything is ok. Thanks

baurceanu commented 3 years ago

ok, i'll try to implement this and create a PR

JFCote commented 3 years ago

Hi @baurchanu ,

Did you start something for this? Just coming back from the holidays and wanted to know if you had something (no pressure! ). Thanks!

baurceanu commented 3 years ago

@JFCote hi, yes I've examined the project and working on this issue. Sorry for the delay. We have too long and discouraging new year holidays in Russia :)

JFCote commented 3 years ago

@baurchanu No problem, take your time!

baurceanu commented 2 years ago

Sorry, I'm not planning to implement this feature anymore, 'cause I migrated my project to zally.

JFCote commented 2 years ago

@baurchanu Looks like a nice project! Thanks for letting me know.

renatomameli commented 3 weeks ago

Is the format even validated? As far as I can see it is not validated at all.