[OpenAPI] Validator Task - #163
Conversation
21b7fc2 to
e62337b
Compare
| Rage::OpenAPI.build | ||
|
|
||
| if Rage::OpenAPI.__warnings.any? | ||
| puts "OpenAPI validation failed. Warnings: #{Rage::OpenAPI.__warnings}" |
There was a problem hiding this comment.
If there are any warnings, Rage::OpenAPI.build will display them anyway.
| puts "OpenAPI validation failed. Warnings: #{Rage::OpenAPI.__warnings}" | |
| puts "OpenAPI validation failed." |
5b6ebd6 to
605c595
Compare
8047efe to
e3c675b
Compare
| def self.__collect_warnings | ||
| @__warnings = [] | ||
| yield | ||
| @__warnings | ||
| ensure | ||
| @__warnings = nil |
There was a problem hiding this comment.
Hello @rsamoilov
What do you think about implementing the warnings accumulator as a wrapper around Rage::OpenAPI.build? I feel like this approach works well because the additional logic doesn't add overhead to the original __log_warn implementation and remains optional, which aligns with the idea that new features shouldn't affect performance for users who don't use them.
There was a problem hiding this comment.
I like the current approach, but I'm not entirely sure what a wrapper around Rage::OpenAPI.build would look like.
I've approved the PR and will be happy to merge it. Let me know if you'd like to rebuild it though.
| def self.__collect_warnings | ||
| @__warnings = [] | ||
| yield | ||
| @__warnings | ||
| ensure | ||
| @__warnings = nil |
There was a problem hiding this comment.
I like the current approach, but I'm not entirely sure what a wrapper around Rage::OpenAPI.build would look like.
I've approved the PR and will be happy to merge it. Let me know if you'd like to rebuild it though.
|
FIY the approach is now a bit different, so I moved the validation Rake task under Rage::CLI - #382. |
openapi:validateRake task that builds the OpenAPI spec and fails (non-zero exit) when any tag warnings were produced during the build.Rage::OpenAPI.__collect_warnings) so docs serving does not retain a process-wide warning list; abort if the app is not booted to avoid a false pass on an empty router.