Comments (4)
Hi,
There is no way to access core validators.
I suggest to declare a new keyword (x-date
for example) in your Document Description for your specific needs then format
keyword can be processed normally.
from openapi4j.
Unfortunately I have no control over the spec files. Although I could iterate the parsed schema and modify it in memory to add the extensions.
I think supporting custom formats without spec modification is desirable. The spec supports custom formats - so validating the added custom formats in addition to the standard ones will be a common use case. Validating keywords other than 'format' will also likely want to fall back to the 'stock' validator after performing the overloaded operation. (e.g I will want to trap all 'type' keywords, but I would prefer to not re-implement the typevalidator).
Can the 'validate' function of the custom validator simply return a boolean which indicates whether openapi4j should proceed onto the core validator after processing?
I can imagine you may want a 'preValidate' and 'postValidate' hook as well(?). The validation hooks are what differentiate openapi4j from other validators so it would be good to make them powerful. But at the least - a boolean which controls the chaining to the core validator would be sufficient.
from openapi4j.
I implemented a chaining behaviour for validators.
Now validate
method returns a boolean to break or continue the chain.
You can have a look at the updated README.md for further info.
Are you able to validate this in latest 0.8-SNAPSHOT?
Thanks
from openapi4j.
Thanks for the changes. I gave them a quick test and it appears to be working.
Another approach could be to pass the next validator in the chain to the validation function as a parameter. The custom validation function can then choose to call the next one or not. It would allow it to post process the validation results, e.g strip out certain errors from core validators. It does put the onus on the custom function to chain correctly however.
But the boolean return approach is likely to be adequate 90% of the time.
from openapi4j.
Related Issues (20)
- int64 or int32 format not identified by openapi4j tool HOT 3
- Mandatory element missing is not throwing error HOT 3
- Some of the optional fields when using oneOf are not being validated HOT 1
- Convenience methods to support easy response validation HOT 3
- Spring Adapter
- Validating data against schema with $ref HOT 2
- Incorrect path pattern for path parameter HOT 2
- Creating schema references programatically HOT 7
- OpenApi3Parser - add ability to provide spec string/stream to parse method HOT 2
- Integer formats not identified in 1.0.5 version openapi4j tool HOT 1
- Scheme that contains path parameters with minus sign in name fails validation HOT 1
- Throw ValidationException on path pattern collision
- Give the option to throw a validation error with no response validator is found
- RequestValidator fails when path params contains minus char HOT 1
- Get the path of an operation HOT 2
- ADDITIONAL_PROPS_RESTRICT = true rejects all attributes HOT 1
- Duplicate properties, Duplicate Headers are not being validated HOT 2
- Remove toString() call to replace NPE with more meaningful message
- Validation of callback URLs can't handle allOf/oneOf/... HOT 3
- Path pattern collision leads to incorrect Path selection
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi4j.