Module: OpenapiFirst
- Defined in:
- lib/openapi_first.rb,
lib/openapi_first/utils.rb,
lib/openapi_first/errors.rb,
lib/openapi_first/router.rb,
lib/openapi_first/version.rb,
lib/openapi_first/operation.rb,
lib/openapi_first/definition.rb,
lib/openapi_first/use_router.rb,
lib/openapi_first/schema_validation.rb,
lib/openapi_first/validation_format.rb,
lib/openapi_first/request_validation.rb,
lib/openapi_first/response_validator.rb,
lib/openapi_first/response_validation.rb,
lib/openapi_first/body_parser_middleware.rb
Defined Under Namespace
Modules: UseRouter, Utils, ValidationFormat
Classes: BodyParserMiddleware, BodyParsingError, Definition, Error, HandlerNotFoundError, NotFoundError, NotImplementedError, Operation, RequestInvalidError, RequestValidation, ResponseBodyInvalidError, ResponseCodeNotFoundError, ResponseContentTypeNotFoundError, ResponseInvalid, ResponseValidation, ResponseValidator, Router, SchemaValidation
Constant Summary
collapse
- OPERATION =
'openapi.operation'
- PARAMS =
'openapi.params'
- REQUEST_BODY =
'openapi.parsed_request_body'
- HANDLER =
'openapi_first.handler'
- VERSION =
'1.0.0.beta3'
Class Method Summary
collapse
Class Method Details
.env ⇒ Object
19
20
21
|
# File 'lib/openapi_first.rb', line 19
def self.env
ENV['RACK_ENV'] || ENV['HANAMI_ENV'] || ENV.fetch('RAILS_ENV', nil)
end
|
.load(spec_path, only: nil) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/openapi_first.rb', line 23
def self.load(spec_path, only: nil)
resolved = Dir.chdir(File.dirname(spec_path)) do
content = YAML.load_file(File.basename(spec_path))
JsonRefs.call(content, resolve_local_ref: true, resolve_file_ref: true)
end
resolved['paths'].filter!(&->(key, _) { only.call(key) }) if only
Definition.new(resolved, spec_path)
end
|