-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
corrects exposing of inline definitions (#503)
- adds changelog entry - adds option to set definition name
- Loading branch information
peter scholz
authored
Sep 19, 2016
1 parent
ef1d5cd
commit 054c54f
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'spec_helper' | ||
require 'grape-entity' | ||
require 'grape-swagger-entity' | ||
|
||
describe 'definition names' do | ||
before :all do | ||
module TestDefinition | ||
module DummyEntities | ||
module WithVeryLongName | ||
module AnotherGroupingModule | ||
class Class1 | ||
class Entity < Grape::Entity | ||
expose :one_thing | ||
end | ||
end | ||
|
||
class Class2 | ||
class Entity < Grape::Entity | ||
expose :another_thing | ||
|
||
def self.entity_name | ||
'FooKlass' | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
class NameApi < Grape::API | ||
add_swagger_documentation models: [ | ||
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class1::Entity, | ||
DummyEntities::WithVeryLongName::AnotherGroupingModule::Class2::Entity | ||
] | ||
end | ||
end | ||
end | ||
|
||
let(:app) { TestDefinition::NameApi } | ||
|
||
subject do | ||
get '/swagger_doc' | ||
JSON.parse(last_response.body)['definitions'] | ||
end | ||
|
||
specify { expect(subject).to include 'AnotherGroupingModuleClass1' } | ||
specify { expect(subject).to include 'FooKlass' } | ||
end |