-
Notifications
You must be signed in to change notification settings - Fork 468
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 param description creation under generator/swagger/param_description
#810
Move swagger param description creation under generator/swagger/param_description
#810
Conversation
5757703
to
2ddf301
Compare
generator/swagger
2f9d697
to
f2bdaf1
Compare
instead of `OpenStruct` Instead of creating an OpenStruct the mimics `ParamDescription` it creates a `ParamDescription` that is marked as `required` and has in it's options the information that is created from path (`added_from_path`) and not from the DSL.
- Introduces `Apipie::Generator::Swagger::ParamDescription::Composite` for nested param descritpions, that recursively loops though it's children. Replaces the `json_schema_obj_from_params_array` & `json_schema_param_defs_from_params_array` with `Apipie::Generator::Swagger::ParamDescription::Composite` - Introduces `Apipie::Generator::Swagger::ParamDescription::Builder` that provides a builder interface responsible for constructing the Swagger parameters. Replaces the `swagger_atomic_param` method with `Apipie::Generator::Swagger::ParamDescription::Builder` Swagger parameters that have some king of logic like `description`, `in`, `name`, `type`, `items` & `enum` live under their respected classes - `Apipie::Generator::Swagger::ParamDescription::Description` - `Apipie::Generator::Swagger::ParamDescription::In` - `Apipie::Generator::Swagger::ParamDescription::Name` - `Apipie::Generator::Swagger::ParamDescription::Type` (This one also handles `items` & `enum` attributes) and get instantiated through the `Apipie::Generator::Swagger::ParamDescription::Builder` api.
f2bdaf1
to
233ff9b
Compare
generator/swagger
generator/swagger/param_description
@@ -434,105 +430,14 @@ def add_missing_params(method, path) | |||
|
|||
missing.each do |name| | |||
warn_path_parameter_not_described(name, path) | |||
result[name.to_sym] = OpenStruct.new({ |
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.
Always happy to see an OpenStruct being removed
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.
would be great to see an update to the README about the new Composite feature.
It's meant to be an internal implementation for swagger generator, maybe once the refactor is done we could have a |
Why
I'm woking on PR to make generators pluggable and allow external generators to be used by apipie.
This PR refactors and moves the param description generation under
lib/apipie/generator/swagger/param_description/
namespace.How
Introduced
Apipie::Generator::Swagger::ParamDescription::Composite
Nested
ParamDescritpion
s likeare converted to swagger by
Apipie::Generator::Swagger::ParamDescription::Composite
that recursively loops though it's children.json_schema_obj_from_params_array
andjson_schema_param_defs_from_params_array
replaced byApipie::Generator::Swagger::Composite
Introduced
Apipie::Generator::Swagger::ParamDescription::Builder
swagger_atomic_param
replaced byApipie::Generator::Swagger::ParamDescription::Builder
that provides an interface responsible for constructing the Swagger parameters.ParamDescription Swagger parameters
Swagger parameters that have some king of logic like
description
,in
,name
,type
,items
,enum
live under their respected classes
Apipie::Generator::Swagger::ParamDescription::Description
Apipie::Generator::Swagger::ParamDescription::In
Apipie::Generator::Swagger::ParamDescription::Name
Apipie::Generator::Swagger::ParamDescription::Type
(This one also handlesitems
&enum
attributes)and get instantiated through the
Apipie::Generator::Swagger::ParamDescription::Builder
's api.Missing attributes
Instead of creating an
OpenStruct
the mimicsParamDescription
we create aParamDescription
from that is required and has in it's options the information that is created from path (added_from_path
) and not from the DSL. (ParamDescription.create_for_missing_param
)Final thoughts
Although this PR adds more lines than it removes, I think it makes it easer to navigate the generator code by having different classes for different responsibilities.