Module: RSpec::OpenAPI
- Defined in:
- lib/rspec/openapi/version.rb,
lib/rspec/openapi.rb
Defined Under Namespace
Modules: ExampleKey, ExchangeRecorder, Extractors, Minitest Classes: ComponentsUpdater=Object.new, Config, DefaultSchema=Object.new, HashHelper=Object.new, KeyTransformer=Object.new, NullableConverter=Object.new, OperationConverter=Object.new, Record, RecordBuilder=Object.new, ResultRecorder, SchemaCleaner=Object.new, SchemaFile, SchemaMerger=Object.new, SchemaSorter=Object.new, StreamParser=Object.new
Constant Summary collapse
- VERSION =
'0.30.0'- SchemaBuilder =
Object.new
- SEQUENTIAL_MEDIA_TYPES =
Streaming media types whose body is a sequence of items, not one document. Their raw body is kept unparsed and split per item (see StreamParser).
[ 'application/jsonl', 'application/x-ndjson', 'application/json-seq', 'text/event-stream', ].freeze
- SUPPORTED_OPENAPI_MAJOR_MINORS =
['3.0', '3.1', '3.2'].freeze
Class Attribute Summary collapse
-
.application_version ⇒ Object
Returns the value of attribute application_version.
-
.comment ⇒ Object
Returns the value of attribute comment.
-
.config_filename ⇒ Object
readonly
Returns the value of attribute config_filename.
-
.description_builder ⇒ Object
Returns the value of attribute description_builder.
-
.enable_example ⇒ Object
Returns the value of attribute enable_example.
-
.enable_example_summary ⇒ Object
Returns the value of attribute enable_example_summary.
-
.example_name_builder ⇒ Object
Returns the value of attribute example_name_builder.
-
.example_types ⇒ Object
Returns the value of attribute example_types.
-
.formats_builder ⇒ Object
Returns the value of attribute formats_builder.
-
.ignored_path_params ⇒ Object
Returns the value of attribute ignored_path_params.
-
.ignored_paths ⇒ Object
Returns the value of attribute ignored_paths.
-
.info ⇒ Object
Returns the value of attribute info.
-
.openapi_version ⇒ Object
Returns the value of attribute openapi_version.
-
.path ⇒ Object
Returns the value of attribute path.
-
.path_records ⇒ Object
Returns the value of attribute path_records.
-
.post_process_hook ⇒ Object
Returns the value of attribute post_process_hook.
-
.request_headers ⇒ Object
Returns the value of attribute request_headers.
-
.response_headers ⇒ Object
Returns the value of attribute response_headers.
-
.root_tags ⇒ Object
Returns the value of attribute root_tags.
-
.security_schemes ⇒ Object
Returns the value of attribute security_schemes.
-
.servers ⇒ Object
Returns the value of attribute servers.
-
.summary_builder ⇒ Object
Returns the value of attribute summary_builder.
-
.tags_builder ⇒ Object
Returns the value of attribute tags_builder.
-
.title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
-
.json_schema_based? ⇒ Boolean
3.1+ drops
nullablein favour of JSON Schema null types. - .openapi_version_at_least?(version) ⇒ Boolean
-
.register_http_methods(methods) ⇒ Object
Allow Rails request specs to issue extra verbs (e.g. QUERY); ActionDispatch otherwise rejects unknown verbs.
- .sequential_media_type?(media_type) ⇒ Boolean
-
.supports_additional_operations? ⇒ Boolean
3.2 adds the
queryfield and theadditionalOperationsmap. -
.supports_item_schema? ⇒ Boolean
3.2 adds
itemSchemafor sequential (streaming) media types.
Class Attribute Details
.application_version ⇒ Object
Returns the value of attribute application_version.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def application_version @application_version end |
.comment ⇒ Object
Returns the value of attribute comment.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def comment @comment end |
.config_filename ⇒ Object (readonly)
Returns the value of attribute config_filename.
95 96 97 |
# File 'lib/rspec/openapi.rb', line 95 def config_filename @config_filename end |
.description_builder ⇒ Object
Returns the value of attribute description_builder.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def description_builder @description_builder end |
.enable_example ⇒ Object
Returns the value of attribute enable_example.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def enable_example @enable_example end |
.enable_example_summary ⇒ Object
Returns the value of attribute enable_example_summary.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def enable_example_summary @enable_example_summary end |
.example_name_builder ⇒ Object
Returns the value of attribute example_name_builder.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def example_name_builder @example_name_builder end |
.example_types ⇒ Object
Returns the value of attribute example_types.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def example_types @example_types end |
.formats_builder ⇒ Object
Returns the value of attribute formats_builder.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def formats_builder @formats_builder end |
.ignored_path_params ⇒ Object
Returns the value of attribute ignored_path_params.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def ignored_path_params @ignored_path_params end |
.ignored_paths ⇒ Object
Returns the value of attribute ignored_paths.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def ignored_paths @ignored_paths end |
.info ⇒ Object
Returns the value of attribute info.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def info @info end |
.openapi_version ⇒ Object
Returns the value of attribute openapi_version.
95 96 97 |
# File 'lib/rspec/openapi.rb', line 95 def openapi_version @openapi_version end |
.path ⇒ Object
Returns the value of attribute path.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def path @path end |
.path_records ⇒ Object
Returns the value of attribute path_records.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def path_records @path_records end |
.post_process_hook ⇒ Object
Returns the value of attribute post_process_hook.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def post_process_hook @post_process_hook end |
.request_headers ⇒ Object
Returns the value of attribute request_headers.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def request_headers @request_headers end |
.response_headers ⇒ Object
Returns the value of attribute response_headers.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def response_headers @response_headers end |
.root_tags ⇒ Object
Returns the value of attribute root_tags.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def @root_tags end |
.security_schemes ⇒ Object
Returns the value of attribute security_schemes.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def security_schemes @security_schemes end |
.servers ⇒ Object
Returns the value of attribute servers.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def servers @servers end |
.summary_builder ⇒ Object
Returns the value of attribute summary_builder.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def summary_builder @summary_builder end |
.tags_builder ⇒ Object
Returns the value of attribute tags_builder.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def @tags_builder end |
.title ⇒ Object
Returns the value of attribute title.
72 73 74 |
# File 'lib/rspec/openapi.rb', line 72 def title @title end |
Class Method Details
.json_schema_based? ⇒ Boolean
3.1+ drops nullable in favour of JSON Schema null types.
113 114 115 |
# File 'lib/rspec/openapi.rb', line 113 def json_schema_based? openapi_version_at_least?('3.1') end |
.openapi_version_at_least?(version) ⇒ Boolean
108 109 110 |
# File 'lib/rspec/openapi.rb', line 108 def openapi_version_at_least?(version) Gem::Version.new(openapi_version) >= Gem::Version.new(version) end |
.register_http_methods(methods) ⇒ Object
Allow Rails request specs to issue extra verbs (e.g. QUERY); ActionDispatch otherwise rejects unknown verbs. No-op outside Rails.
133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/rspec/openapi.rb', line 133 def register_http_methods(methods) # simplecov:disable branch non-Rails guard for roda/hanami; the suite always loads Rails return unless defined?(ActionDispatch::Request::HTTP_METHODS) # simplecov:enable Array(methods).each do |method| verb = method.to_s.upcase next if ActionDispatch::Request::HTTP_METHODS.include?(verb) ActionDispatch::Request::HTTP_METHODS << verb ActionDispatch::Request::HTTP_METHOD_LOOKUP[verb] = verb.downcase.to_sym end end |
.sequential_media_type?(media_type) ⇒ Boolean
127 128 129 |
# File 'lib/rspec/openapi.rb', line 127 def sequential_media_type?(media_type) SEQUENTIAL_MEDIA_TYPES.include?(media_type) end |
.supports_additional_operations? ⇒ Boolean
3.2 adds the query field and the additionalOperations map.
118 119 120 |
# File 'lib/rspec/openapi.rb', line 118 def supports_additional_operations? openapi_version_at_least?('3.2') end |
.supports_item_schema? ⇒ Boolean
3.2 adds itemSchema for sequential (streaming) media types.
123 124 125 |
# File 'lib/rspec/openapi.rb', line 123 def supports_item_schema? openapi_version_at_least?('3.2') end |