-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Swagger types and warnings under /generator
namespace
#803
Conversation
/generator
namespace
609bed4
to
d827970
Compare
d827970
to
70fbc23
Compare
`Apipie::Generator::Swagger::TypeExtractor` is responsible to identify the Swagger type from a given validator or default to `string` if no validator is given.
70fbc23
to
4d8688e
Compare
private | ||
|
||
def extract | ||
expected_type = if string? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer preventing wide indent by adding a return after the assignation.
can you update to
expected_type =
if string?
:string
elsif boolean?
:boolean
elsif enum?
:enum
else
@validator.expected_type.to_sym
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine with me. 036e748
Should we add it as a Rubocop cop ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really cool refactor, I need more time to review, but I intend to merge...
elsif enum? | ||
:enum | ||
else | ||
@validator.expected_type.to_sym |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that I am reading this properly.. maybe this was the original code... but I wonder why the if/elsif/elsif/else
when @validator.expected_type.to_sym
probably already return the right value for string
, boolean
, and enum
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was confusing to me as well.
There are a couple of issues we handle here
ParamDescription
's validator can be
nil
Apipie::Validator::BaseValidator
ResponseDescriptionAdapter::PropDesc::Validator
Updated Yard comment dc88775
In case of nil we want to default to string
Apipie::Validator::EnumValidator#expected_type
returns string
ResponseDescriptionAdapter::PropDesc::Validator#expected_type
can we whatever by if we give it values that are [true, false]
we need to result into boolean
.
Update Yard comment
Why
I'm woking on PR to make generators pluggable and allow external generators to be used by apipie.
This PR is a first step to start moving the Swagger 2.0 generator under
/generator
namespace.How
It introduces
Apipie::Generator::Swagger::TypeExtractor
that is responsible to convert anApipie::Validator
to a Swagger typeApipie::Generator::Swagger::Warning
&Apipie::Generator::Swagger::WarningWriter
to handle conditional logic on when a warning should be logged or not.It's just a refactor and does not add any new functionality for the end user and it should not introduce any breaking changes.