Module: SwaggerYard
- Defined in:
- lib/swagger_yard.rb,
lib/swagger_yard/api.rb,
lib/swagger_yard/type.rb,
lib/swagger_yard/model.rb,
lib/swagger_yard/swagger.rb,
lib/swagger_yard/version.rb,
lib/swagger_yard/property.rb,
lib/swagger_yard/operation.rb,
lib/swagger_yard/parameter.rb,
lib/swagger_yard/type_parser.rb,
lib/swagger_yard/authorization.rb,
lib/swagger_yard/configuration.rb,
lib/swagger_yard/api_declaration.rb,
lib/swagger_yard/resource_listing.rb
Defined Under Namespace
Classes: Api, ApiDeclaration, Authorization, Configuration, Info, Model, Operation, Parameter, Property, ResourceListing, Swagger, Type, TypeParser
Constant Summary collapse
- VERSION =
"0.3.7"
Class Method Summary collapse
- .config ⇒ Object
-
.configure {|config| ... } ⇒ Object
Configuration for Swagger Yard, use like:.
-
.register_custom_yard_tags! ⇒ Object
Register some custom yard tags used by swagger-ui.
-
.yard_class_objects_from_file(file_path) ⇒ YARD
Parse all objects in the file and return the class objects found.
-
.yard_objects_from_file(file_path, *types) ⇒ YARD
Use YARD to parse object tags from a file.
Class Method Details
.config ⇒ Object
32 33 34 |
# File 'lib/swagger_yard.rb', line 32 def config @configuration ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Configuration for Swagger Yard, use like:
SwaggerYard.configure do |config|
config.swagger_version = "1.1"
config.api_version = "0.1"
config.doc_base_path = "http://swagger.example.com/doc"
config.api_base_path = "http://swagger.example.com/api"
config.reload = true # Rails.env.development?
end
28 29 30 |
# File 'lib/swagger_yard.rb', line 28 def configure yield config end |
.register_custom_yard_tags! ⇒ Object
Register some custom yard tags used by swagger-ui
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/swagger_yard.rb', line 60 def ::YARD::Tags::Library.define_tag("Api resource", :resource) ::YARD::Tags::Library.define_tag("Resource path", :resource_path) # TODO: remove deprecated tag ::YARD::Tags::Library.define_tag("Api path", :path, :with_types) ::YARD::Tags::Library.define_tag("Parameter", :parameter, :with_types_name_and_default) ::YARD::Tags::Library.define_tag("Response type", :response_type, :with_types) ::YARD::Tags::Library.define_tag("Error response message", :error_message, :with_types_and_name) ::YARD::Tags::Library.define_tag("Api Summary", :summary) ::YARD::Tags::Library.define_tag("Model resource", :model) ::YARD::Tags::Library.define_tag("Model superclass", :inherits) ::YARD::Tags::Library.define_tag("Model property", :property, :with_types_name_and_default) ::YARD::Tags::Library.define_tag("Model discriminator", :discriminator, :with_types_name_and_default) ::YARD::Tags::Library.define_tag("Authorization", :authorization, :with_types_and_name) ::YARD::Tags::Library.define_tag("Authorization Use", :authorize_with) end |
.yard_class_objects_from_file(file_path) ⇒ YARD
Parse all objects in the file and return the class objects found.
54 55 56 |
# File 'lib/swagger_yard.rb', line 54 def yard_class_objects_from_file(file_path) yard_objects_from_file(file_path, :class) end |
.yard_objects_from_file(file_path, *types) ⇒ YARD
Use YARD to parse object tags from a file
43 44 45 46 |
# File 'lib/swagger_yard.rb', line 43 def yard_objects_from_file(file_path, *types) ::YARD.parse(file_path) ::YARD::Registry.all(*types).select {|co| co.file == file_path } end |