Class: Swagger::V2::API
- Inherits:
-
API
- Object
- Hashie::Dash
- SwaggerObject
- API
- Swagger::V2::API
- Defined in:
- lib/swagger/v2/api.rb
Overview
Class representing the top level “Swagger Object”
Instance Attribute Summary
Attributes inherited from SwaggerObject
Instance Method Summary collapse
-
#fully_validate ⇒ true
Validates this object against the Swagger specification and returns all detected errors.
-
#operations ⇒ Array<Operation>
All operations under all paths.
-
#uri_template ⇒ Swagger::URITemplate
A complete (including host) URI Template for the basePath.
-
#validate ⇒ true
Validates this object against the Swagger specification and returns the first detected error.
Methods inherited from API
Methods inherited from SwaggerObject
field, #initialize, required_field
Methods included from Attachable
#attach_parent, #attach_to_children, #root
Constructor Details
This class inherits a constructor from Swagger::API
Instance Method Details
#fully_validate ⇒ true
Validates this object against the Swagger specification and returns all detected errors. Slower than #validate.
58 59 60 61 62 63 |
# File 'lib/swagger/v2/api.rb', line 58 def fully_validate # NOTE: fully_validate is ideal, but very slow with the current schema/validator errors = JSON::Validator.fully_validate(swagger_schema, to_json) fail Swagger::InvalidDefinition, errors unless errors.empty? true end |
#operations ⇒ Array<Operation>
All operations under all paths
41 42 43 44 45 46 |
# File 'lib/swagger/v2/api.rb', line 41 def operations # Perhaps not the best way... paths.values.map do | path | path.operations.values end.flatten end |
#uri_template ⇒ Swagger::URITemplate
A complete (including host) URI Template for the basePath.
50 51 52 |
# File 'lib/swagger/v2/api.rb', line 50 def uri_template Swagger::URITemplate.new("#{host}#{basePath}") end |
#validate ⇒ true
Validates this object against the Swagger specification and returns the first detected error. Faster than #fully_validate.
69 70 71 72 73 |
# File 'lib/swagger/v2/api.rb', line 69 def validate JSON::Validator.validate!(swagger_schema, to_json) rescue JSON::Schema::ValidationError => e raise Swagger::InvalidDefinition, e. end |