Skip to content

Commit 2a13b1b

Browse files
authored
Merge pull request #64 from numbata/pass_x_extension_docs_for_objects
2 parents f001b87 + 7245469 commit 2a13b1b

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#### Features
44

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

78
#### Fixes
89

@@ -14,7 +15,6 @@
1415

1516
* [#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).
1617
* [#61](https://github.com/ruby-grape/grape-swagger-entity/pull/61): Migrate from Travis to GHA for CI - [@mscrivo](https://github.com/mscrivo).
17-
* Your contribution here.
1818

1919
### 0.5.1 (2020/06/30)
2020

lib/grape-swagger/entity/attribute_parser.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def call(entity_options)
1919
entity_model_type = entity_model_type(name, entity_options)
2020
return entity_model_type unless documentation
2121

22+
add_extension_documentation(entity_model_type, documentation)
2223
add_array_documentation(entity_model_type, documentation) if documentation[:is_array]
2324

2425
entity_model_type
@@ -74,7 +75,7 @@ def ambiguous_model_type?(type)
7475

7576
def data_type_from(documentation)
7677
documented_type = documentation[:type]
77-
documented_type ||= (documentation[:documentation] && documentation[:documentation][:type])
78+
documented_type ||= documentation[:documentation] && documentation[:documentation][:type]
7879

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

spec/grape-swagger/entities/response_model_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def app
6060
'kind3' => { '$ref' => '#/definitions/ThisApi_Entities_Kind', 'description' => 'Tertiary kind.' },
6161
'tags' => { 'type' => 'array', 'items' => { '$ref' => '#/definitions/ThisApi_Entities_Tag' },
6262
'description' => 'Tags.' },
63-
'relation' => { '$ref' => '#/definitions/ThisApi_Entities_Relation', 'description' => 'A related model.' },
63+
'relation' => { '$ref' => '#/definitions/ThisApi_Entities_Relation', 'description' => 'A related model.',
64+
'x-other' => 'stuff' },
6465
'code' => { 'type' => 'string', 'description' => 'Error code' },
6566
'message' => { 'type' => 'string', 'description' => 'Error message' },
6667
'attr' => { 'type' => 'string', 'description' => 'Attribute' } },

spec/support/shared_contexts/this_api.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ class Something < Grape::Entity
3636
expose :kind3, using: ThisApi::Entities::Kind, documentation: { desc: 'Tertiary kind.' }
3737
expose :tags, using: ThisApi::Entities::Tag, documentation: { desc: 'Tags.', is_array: true }
3838
expose :relation, using: ThisApi::Entities::Relation,
39-
documentation: { type: 'ThisApi::Relation', desc: 'A related model.' }
39+
documentation: {
40+
type: 'ThisApi::Relation',
41+
desc: 'A related model.',
42+
x: { other: 'stuff' }
43+
}
4044
expose :merged_attribute, using: ThisApi::Entities::Nested, merge: true
4145
end
4246
end

0 commit comments

Comments
 (0)