openapi_first 0.7.0.alpha1 → 3.1.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +585 -2
- data/LICENSE.txt +21 -0
- data/README.md +360 -114
- data/lib/openapi_first/builder.rb +214 -0
- data/lib/openapi_first/child_configuration.rb +26 -0
- data/lib/openapi_first/configuration.rb +76 -0
- data/lib/openapi_first/definition.rb +98 -13
- data/lib/openapi_first/error_response.rb +40 -0
- data/lib/openapi_first/error_responses/default.rb +74 -0
- data/lib/openapi_first/error_responses/jsonapi.rb +60 -0
- data/lib/openapi_first/errors.rb +40 -0
- data/lib/openapi_first/failure.rb +77 -0
- data/lib/openapi_first/file_loader.rb +22 -0
- data/lib/openapi_first/header.rb +9 -0
- data/lib/openapi_first/json.rb +25 -0
- data/lib/openapi_first/middlewares/request_validation.rb +58 -0
- data/lib/openapi_first/middlewares/response_validation.rb +41 -0
- data/lib/openapi_first/parsed_request.rb +5 -0
- data/lib/openapi_first/ref_resolver.rb +193 -0
- data/lib/openapi_first/registry.rb +44 -0
- data/lib/openapi_first/request.rb +79 -0
- data/lib/openapi_first/request_body_parsers.rb +64 -0
- data/lib/openapi_first/request_validator.rb +32 -0
- data/lib/openapi_first/response.rb +43 -0
- data/lib/openapi_first/response_body_parsers.rb +31 -0
- data/lib/openapi_first/response_parser.rb +50 -0
- data/lib/openapi_first/response_validator.rb +16 -48
- data/lib/openapi_first/router/find_content.rb +17 -0
- data/lib/openapi_first/router/find_response.rb +53 -0
- data/lib/openapi_first/router/path_template.rb +48 -0
- data/lib/openapi_first/router.rb +84 -57
- data/lib/openapi_first/schema/hash.rb +39 -0
- data/lib/openapi_first/schema/validation_error.rb +45 -0
- data/lib/openapi_first/schema/validation_result.rb +30 -0
- data/lib/openapi_first/test/app.rb +30 -0
- data/lib/openapi_first/test/callable.rb +25 -0
- data/lib/openapi_first/test/configuration.rb +76 -0
- data/lib/openapi_first/test/coverage/covered_request.rb +11 -0
- data/lib/openapi_first/test/coverage/covered_response.rb +11 -0
- data/lib/openapi_first/test/coverage/plan.rb +77 -0
- data/lib/openapi_first/test/coverage/request_task.rb +42 -0
- data/lib/openapi_first/test/coverage/response_task.rb +42 -0
- data/lib/openapi_first/test/coverage/route_task.rb +13 -0
- data/lib/openapi_first/test/coverage/terminal_formatter.rb +115 -0
- data/lib/openapi_first/test/coverage/tracker.rb +32 -0
- data/lib/openapi_first/test/coverage.rb +102 -0
- data/lib/openapi_first/test/methods.rb +62 -0
- data/lib/openapi_first/test/minitest_helpers.rb +28 -0
- data/lib/openapi_first/test/observe.rb +37 -0
- data/lib/openapi_first/test/observer_middleware.rb +23 -0
- data/lib/openapi_first/test/plain_helpers.rb +31 -0
- data/lib/openapi_first/test.rb +171 -0
- data/lib/openapi_first/validated_request.rb +79 -0
- data/lib/openapi_first/validated_response.rb +53 -0
- data/lib/openapi_first/validators/request_body.rb +25 -0
- data/lib/openapi_first/validators/request_parameters.rb +49 -0
- data/lib/openapi_first/validators/response_body.rb +27 -0
- data/lib/openapi_first/validators/response_headers.rb +40 -0
- data/lib/openapi_first/version.rb +1 -1
- data/lib/openapi_first.rb +67 -35
- metadata +99 -133
- data/.github/CODEOWNERS +0 -1
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.rubocop.yml +0 -14
- data/.travis.yml +0 -8
- data/Gemfile +0 -11
- data/Gemfile.lock +0 -126
- data/Rakefile +0 -15
- data/benchmarks/Gemfile +0 -13
- data/benchmarks/Gemfile.lock +0 -144
- data/benchmarks/apps/committee.ru +0 -30
- data/benchmarks/apps/grape.ru +0 -21
- data/benchmarks/apps/hanami_router.ru +0 -14
- data/benchmarks/apps/openapi.yaml +0 -86
- data/benchmarks/apps/openapi_first.ru +0 -22
- data/benchmarks/apps/openapi_first_resolve_only.ru +0 -23
- data/benchmarks/apps/sinatra.ru +0 -26
- data/benchmarks/apps/syro.ru +0 -25
- data/benchmarks/benchmarks.rb +0 -46
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/examples/README.md +0 -13
- data/examples/app.rb +0 -12
- data/examples/config.ru +0 -7
- data/examples/openapi.yaml +0 -29
- data/lib/openapi_first/app.rb +0 -27
- data/lib/openapi_first/coverage.rb +0 -28
- data/lib/openapi_first/operation.rb +0 -48
- data/lib/openapi_first/operation_resolver.rb +0 -43
- data/lib/openapi_first/request_validation.rb +0 -144
- data/lib/openapi_first/utils.rb +0 -31
- data/lib/openapi_first/validation.rb +0 -15
- data/lib/openapi_first/validation_format.rb +0 -31
- data/openapi_first.gemspec +0 -46
data/lib/openapi_first/utils.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'hanami/utils/string'
|
|
4
|
-
|
|
5
|
-
module OpenapiFirst
|
|
6
|
-
module Utils
|
|
7
|
-
def self.underscore(string)
|
|
8
|
-
Hanami::Utils::String.underscore(string)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.classify(string)
|
|
12
|
-
Hanami::Utils::String.classify(string)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.deep_stringify(params) # rubocop:disable Metrics/MethodLength
|
|
16
|
-
params.each_with_object({}) do |(key, value), output|
|
|
17
|
-
output[key.to_s] =
|
|
18
|
-
case value
|
|
19
|
-
when ::Hash
|
|
20
|
-
deep_stringify(value)
|
|
21
|
-
when Array
|
|
22
|
-
value.map do |item|
|
|
23
|
-
item.is_a?(::Hash) ? deep_stringify(item) : item
|
|
24
|
-
end
|
|
25
|
-
else
|
|
26
|
-
value
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module OpenapiFirst
|
|
4
|
-
module ValidationFormat
|
|
5
|
-
SIMPLE_TYPES = %w[string integer].freeze
|
|
6
|
-
|
|
7
|
-
# rubocop:disable Metrics/MethodLength
|
|
8
|
-
def self.error_details(error)
|
|
9
|
-
if error['type'] == 'pattern'
|
|
10
|
-
{
|
|
11
|
-
title: 'is not valid',
|
|
12
|
-
detail: "does not match pattern '#{error['schema']['pattern']}'"
|
|
13
|
-
}
|
|
14
|
-
elsif error['type'] == 'required'
|
|
15
|
-
missing_keys = error['details']['missing_keys']
|
|
16
|
-
{
|
|
17
|
-
title: "is missing required properties: #{missing_keys.join(', ')}"
|
|
18
|
-
}
|
|
19
|
-
elsif SIMPLE_TYPES.include?(error['type'])
|
|
20
|
-
{
|
|
21
|
-
title: "should be a #{error['type']}"
|
|
22
|
-
}
|
|
23
|
-
elsif error['schema'] == false
|
|
24
|
-
{ title: 'unknown fields are not allowed' }
|
|
25
|
-
else
|
|
26
|
-
{ title: 'is not valid' }
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
# rubocop:enable Metrics/MethodLength
|
|
30
|
-
end
|
|
31
|
-
end
|
data/openapi_first.gemspec
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
lib = File.expand_path('lib', __dir__)
|
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
-
require 'openapi_first/version'
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name = 'openapi_first'
|
|
9
|
-
spec.version = OpenapiFirst::VERSION
|
|
10
|
-
spec.authors = ['Andreas Haller']
|
|
11
|
-
spec.email = ['andreas.haller@posteo.de']
|
|
12
|
-
spec.licenses = ['MIT']
|
|
13
|
-
|
|
14
|
-
spec.summary = 'Implement REST APIs based on OpenApi.'
|
|
15
|
-
spec.homepage = 'https://github.com/ahx/openapi_first'
|
|
16
|
-
|
|
17
|
-
if spec.respond_to?(:metadata)
|
|
18
|
-
spec.metadata['https://github.com/ahx/openapi_first'] = spec.homepage
|
|
19
|
-
spec.metadata['source_code_uri'] = 'https://github.com/ahx/openapi_first'
|
|
20
|
-
spec.metadata['changelog_uri'] = 'https://github.com/ahx/openapi_first/blob/master/CHANGELOG.md'
|
|
21
|
-
else
|
|
22
|
-
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
|
23
|
-
'public gem pushes.'
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
27
|
-
`git ls-files -z`
|
|
28
|
-
.split("\x0")
|
|
29
|
-
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
30
|
-
.reject { |f| %w[Dockerfile Jenkinsfile .tool-versions].include?(f) }
|
|
31
|
-
end
|
|
32
|
-
spec.bindir = 'exe'
|
|
33
|
-
spec.require_paths = ['lib']
|
|
34
|
-
|
|
35
|
-
spec.add_dependency 'hanami-router', '~> 2.0.alpha2'
|
|
36
|
-
spec.add_dependency 'hanami-utils', '~> 2.0.alpha1'
|
|
37
|
-
spec.add_dependency 'json_schemer', '~> 0.2'
|
|
38
|
-
spec.add_dependency 'multi_json', '~> 1.14'
|
|
39
|
-
spec.add_dependency 'oas_parser', '~> 0.24'
|
|
40
|
-
spec.add_dependency 'rack', '~> 2.2'
|
|
41
|
-
|
|
42
|
-
spec.add_development_dependency 'bundler', '~> 2'
|
|
43
|
-
spec.add_development_dependency 'rack-test', '~> 1'
|
|
44
|
-
spec.add_development_dependency 'rake', '~> 13'
|
|
45
|
-
spec.add_development_dependency 'rspec', '~> 3'
|
|
46
|
-
end
|