Skip to content
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

Merged
merged 4 commits into from
Jan 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/apipie/generator/swagger/type_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ def extract_with_warnings(warnings = {})
private

def extract
expected_type = if string?
:string
elsif boolean?
:boolean
elsif enum?
:enum
else
@validator.expected_type.to_sym
end
expected_type =
if string?
:string
elsif boolean?
:boolean
elsif enum?
:enum
else
@validator.expected_type.to_sym
Copy link
Collaborator

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 ?

Copy link
Contributor Author

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.

end

TYPES[expected_type] || @validator.expected_type
end
Expand Down