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

Pass extension documentation into schema #64

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#### Features

* Your contribution here.
* [#64](https://github.com/ruby-grape/grape-swagger-entity/pull/64): Pass extension documentation into schema - [@numbata](https://github.com/numbata).

#### Fixes

Expand All @@ -14,7 +15,6 @@

* [#60](https://github.com/ruby-grape/grape-swagger-entity/pull/60): Examples on arrays should be directly on the property, not on the item - [@collinsauve](https://github.com/collinsauve).
* [#61](https://github.com/ruby-grape/grape-swagger-entity/pull/61): Migrate from Travis to GHA for CI - [@mscrivo](https://github.com/mscrivo).
* Your contribution here.

### 0.5.1 (2020/06/30)

Expand Down
3 changes: 2 additions & 1 deletion lib/grape-swagger/entity/attribute_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def call(entity_options)
entity_model_type = entity_model_type(name, entity_options)
return entity_model_type unless documentation

add_extension_documentation(entity_model_type, documentation)
add_array_documentation(entity_model_type, documentation) if documentation[:is_array]

entity_model_type
Expand Down Expand Up @@ -74,7 +75,7 @@ def ambiguous_model_type?(type)

def data_type_from(documentation)
documented_type = documentation[:type]
documented_type ||= (documentation[:documentation] && documentation[:documentation][:type])
documented_type ||= documentation[:documentation] && documentation[:documentation][:type]

data_type = GrapeSwagger::DocMethods::DataType.call(documented_type)

Expand Down
3 changes: 2 additions & 1 deletion spec/grape-swagger/entities/response_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def app
'kind3' => { '$ref' => '#/definitions/ThisApi_Entities_Kind', 'description' => 'Tertiary kind.' },
'tags' => { 'type' => 'array', 'items' => { '$ref' => '#/definitions/ThisApi_Entities_Tag' },
'description' => 'Tags.' },
'relation' => { '$ref' => '#/definitions/ThisApi_Entities_Relation', 'description' => 'A related model.' },
'relation' => { '$ref' => '#/definitions/ThisApi_Entities_Relation', 'description' => 'A related model.',
'x-other' => 'stuff' },
'code' => { 'type' => 'string', 'description' => 'Error code' },
'message' => { 'type' => 'string', 'description' => 'Error message' },
'attr' => { 'type' => 'string', 'description' => 'Attribute' } },
Expand Down
6 changes: 5 additions & 1 deletion spec/support/shared_contexts/this_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class Something < Grape::Entity
expose :kind3, using: ThisApi::Entities::Kind, documentation: { desc: 'Tertiary kind.' }
expose :tags, using: ThisApi::Entities::Tag, documentation: { desc: 'Tags.', is_array: true }
expose :relation, using: ThisApi::Entities::Relation,
documentation: { type: 'ThisApi::Relation', desc: 'A related model.' }
documentation: {
type: 'ThisApi::Relation',
desc: 'A related model.',
x: { other: 'stuff' }
}
expose :merged_attribute, using: ThisApi::Entities::Nested, merge: true
end
end
Expand Down
Loading