-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make camelizing of model properties configurable.
* Fix model tag name so it is the same case as the symbol passed in. A swagger_model :Tag was being put into the json models hash as 'tag' instead of 'Tag' * Created ApiDeclarationFileMetadata class to make it clear the fields that are needed on the ApiDeclarationFile metadata object * Updated readme
- Loading branch information
1 parent
b58a49a
commit 8bbef3a
Showing
8 changed files
with
218 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,18 @@ | ||
module Swagger | ||
module Docs | ||
class ApiDeclarationFileMetadata | ||
DEFAULT_SWAGGER_VERSION = "1.2" | ||
|
||
attr_reader :api_version, :path, :base_path, :controller_base_path, :swagger_version, :camelize_model_properties | ||
|
||
def initialize(api_version, path, base_path, controller_base_path, options={}) | ||
@api_version = api_version | ||
@path = path | ||
@base_path = base_path | ||
@controller_base_path = controller_base_path | ||
@swagger_version = options.fetch(:swagger_version, DEFAULT_SWAGGER_VERSION) | ||
@camelize_model_properties = options.fetch(:camelize_model_properties, true) | ||
end | ||
end | ||
end | ||
end |
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
55 changes: 55 additions & 0 deletions
55
spec/lib/swagger/docs/api_declaration_file_metadata_spec.rb
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,55 @@ | ||
require 'spec_helper' | ||
|
||
describe Swagger::Docs::ApiDeclarationFileMetadata do | ||
|
||
describe "#initialize" do | ||
it "sets the api_version property" do | ||
metadata = described_class.new("1.0", "path", "basePath", "controllerBasePath") | ||
|
||
expect(metadata.api_version).to eq("1.0") | ||
end | ||
|
||
it "sets the path property" do | ||
metadata = described_class.new("1.0", "path", "basePath", "controllerBasePath") | ||
|
||
expect(metadata.path).to eq("path") | ||
end | ||
|
||
it "sets the base_path property" do | ||
metadata = described_class.new("1.0", "path", "basePath", "controllerBasePath") | ||
|
||
expect(metadata.base_path).to eq("basePath") | ||
end | ||
|
||
it "sets the controller_base_path property" do | ||
metadata = described_class.new("1.0", "path", "basePath", "controllerBasePath") | ||
|
||
expect(metadata.controller_base_path).to eq("controllerBasePath") | ||
end | ||
|
||
it "defaults the swagger_version property to DEFAULT_SWAGGER_VERSION" do | ||
metadata = described_class.new("1.0", "path", "basePath", "controllerBasePath") | ||
|
||
expect(metadata.swagger_version).to eq(described_class::DEFAULT_SWAGGER_VERSION) | ||
end | ||
|
||
it "allows the swagger_version property to be_overriden" do | ||
metadata = described_class.new("1.0", "path", "basePath", "controllerBasePath", swagger_version: "2.0") | ||
|
||
expect(metadata.swagger_version).to eq("2.0") | ||
end | ||
|
||
|
||
it "defaults the camelize_model_properties property to true" do | ||
metadata = described_class.new("1.0", "path", "basePath", "controllerBasePath") | ||
|
||
expect(metadata.camelize_model_properties).to eq(true) | ||
end | ||
|
||
it "allows the camelize_model_properties property to be overidden" do | ||
metadata = described_class.new("1.0", "path", "basePath", "controllerBasePath", camelize_model_properties: false) | ||
|
||
expect(metadata.camelize_model_properties).to eq(false) | ||
end | ||
end | ||
end |
Oops, something went wrong.