Module: OasRails

Defined in:
lib/oas_rails.rb,
lib/oas_rails/utils.rb,
lib/oas_rails/engine.rb,
lib/oas_rails/version.rb,
lib/oas_rails/spec/tag.rb,
lib/oas_rails/oas_route.rb,
lib/oas_rails/spec/info.rb,
lib/oas_rails/spec/paths.rb,
lib/oas_rails/spec/server.rb,
lib/oas_rails/spec/contact.rb,
lib/oas_rails/spec/license.rb,
lib/oas_rails/configuration.rb,
lib/oas_rails/spec/hashable.rb,
lib/oas_rails/spec/response.rb,
lib/oas_rails/spec/specable.rb,
lib/oas_rails/spec/operation.rb,
lib/oas_rails/spec/parameter.rb,
lib/oas_rails/spec/path_item.rb,
lib/oas_rails/spec/reference.rb,
lib/oas_rails/spec/responses.rb,
lib/oas_rails/spec/components.rb,
lib/oas_rails/spec/media_type.rb,
lib/oas_rails/yard/example_tag.rb,
lib/oas_rails/spec/request_body.rb,
lib/oas_rails/yard/response_tag.rb,
lib/oas_rails/spec/specification.rb,
lib/oas_rails/yard/parameter_tag.rb,
app/helpers/oas_rails/test_helper.rb,
app/jobs/oas_rails/application_job.rb,
lib/oas_rails/json_schema_generator.rb,
lib/oas_rails/yard/request_body_tag.rb,
lib/oas_rails/yard/oas_rails_factory.rb,
app/helpers/oas_rails/oas_rails_helper.rb,
lib/oas_rails/builders/content_builder.rb,
lib/oas_rails/builders/esquema_builder.rb,
app/models/oas_rails/application_record.rb,
lib/oas_rails/builders/response_builder.rb,
lib/oas_rails/yard/response_example_tag.rb,
app/helpers/oas_rails/application_helper.rb,
app/mailers/oas_rails/application_mailer.rb,
lib/oas_rails/builders/operation_builder.rb,
lib/oas_rails/builders/parameter_builder.rb,
lib/oas_rails/builders/path_item_builder.rb,
lib/oas_rails/builders/responses_builder.rb,
lib/oas_rails/extractors/route_extractor.rb,
lib/oas_rails/builders/parameters_builder.rb,
lib/oas_rails/builders/request_body_builder.rb,
lib/oas_rails/yard/request_body_example_tag.rb,
lib/oas_rails/extractors/oas_route_extractor.rb,
app/controllers/oas_rails/oas_rails_controller.rb,
app/controllers/oas_rails/application_controller.rb,
lib/generators/oas_rails/config/config_generator.rb,
lib/oas_rails/extractors/render_response_extractor.rb

Defined Under Namespace

Modules: ApplicationHelper, Builders, Extractors, Generators, JsonSchemaGenerator, OasRailsHelper, Spec, TestHelper, Utils, YARD Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, Configuration, Engine, OasRailsController, OasRoute

Constant Summary collapse

VERSION =
"0.8.2"
DEFAULT_SECURITY_SCHEMES =
{
  api_key_cookie: {
    type: "apiKey",
    in: "cookie",
    name: "api_key",
    description: "An API key that will be supplied in a named cookie."
  },
  api_key_header: {
    type: "apiKey",
    in: "header",
    name: "X-API-Key",
    description: "An API key that will be supplied in a named header."
  },
  api_key_query: {
    type: "apiKey",
    in: "query",
    name: "apiKey",
    description: "An API key that will be supplied in a named query parameter."
  },
  basic: {
    type: "http",
    scheme: "basic",
    description: "Basic auth that takes a base64'd combination of `user:password`."
  },
  bearer: {
    type: "http",
    scheme: "bearer",
    description: "A bearer token that will be supplied within an `Authorization` header as `bearer <token>`."
  },
  bearer_jwt: {
    type: "http",
    scheme: "bearer",
    bearerFormat: "JWT",
    description: "A bearer token that will be supplied within an `Authorization` header as `bearer <token>`. In this case, the format of the token is specified as JWT."
  },
  mutual_tls: {
    type: "mutualTLS",
    description: "Requires a specific mutual TLS certificate to use when making an HTTP request."
  }
}.freeze

Class Method Summary collapse

Class Method Details

.buildObject



65
66
67
68
69
70
# File 'lib/oas_rails.rb', line 65

def build
  oas = Spec::Specification.new
  oas.build

  oas.to_spec
end

.configObject



78
79
80
# File 'lib/oas_rails.rb', line 78

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Configurations for make the OasRails engine Work.

Yields:



73
74
75
76
# File 'lib/oas_rails.rb', line 73

def configure
  OasRails.configure_yard!
  yield config
end

.configure_yard!Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/oas_rails.rb', line 82

def configure_yard!
  ::YARD::Tags::Library.default_factory = YARD::OasRailsFactory
  yard_tags = {
    'Request body' => [:request_body, :with_request_body],
    'Request body Example' => [:request_body_example, :with_request_body_example],
    'Parameter' => [:parameter, :with_parameter],
    'Response' => [:response, :with_response],
    'Response Example' => [:response_example, :with_response_example],
    'Endpoint Tags' => [:tags],
    'Summary' => [:summary],
    'No Auth' => [:no_auth],
    'Auth methods' => [:auth, :with_types]
  }
  yard_tags.each do |tag_name, (method_name, handler)|
    ::YARD::Tags::Library.define_tag(tag_name, method_name, handler)
  end
end