Module: RSpec::OpenAPI
- Defined in:
- lib/rspec/openapi/version.rb,
lib/rspec/openapi.rb
Defined Under Namespace
Modules: ExampleKey, ExchangeRecorder, Extractors, Minitest, ParallelRecords 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.33.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.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def application_version @application_version end |
.comment ⇒ Object
Returns the value of attribute comment.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def comment @comment end |
.config_filename ⇒ Object (readonly)
Returns the value of attribute config_filename.
96 97 98 |
# File 'lib/rspec/openapi.rb', line 96 def config_filename @config_filename end |
.description_builder ⇒ Object
Returns the value of attribute description_builder.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def description_builder @description_builder end |
.enable_example ⇒ Object
Returns the value of attribute enable_example.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def enable_example @enable_example end |
.enable_example_summary ⇒ Object
Returns the value of attribute enable_example_summary.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def enable_example_summary @enable_example_summary end |
.example_name_builder ⇒ Object
Returns the value of attribute example_name_builder.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def example_name_builder @example_name_builder end |
.example_types ⇒ Object
Returns the value of attribute example_types.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def example_types @example_types end |
.formats_builder ⇒ Object
Returns the value of attribute formats_builder.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def formats_builder @formats_builder end |
.ignored_path_params ⇒ Object
Returns the value of attribute ignored_path_params.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def ignored_path_params @ignored_path_params end |
.ignored_paths ⇒ Object
Returns the value of attribute ignored_paths.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def ignored_paths @ignored_paths end |
.info ⇒ Object
Returns the value of attribute info.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def info @info end |
.openapi_version ⇒ Object
Returns the value of attribute openapi_version.
96 97 98 |
# File 'lib/rspec/openapi.rb', line 96 def openapi_version @openapi_version end |
.path ⇒ Object
Returns the value of attribute path.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def path @path end |
.path_records ⇒ Object
Returns the value of attribute path_records.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def path_records @path_records end |
.post_process_hook ⇒ Object
Returns the value of attribute post_process_hook.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def post_process_hook @post_process_hook end |
.request_headers ⇒ Object
Returns the value of attribute request_headers.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def request_headers @request_headers end |
.response_headers ⇒ Object
Returns the value of attribute response_headers.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def response_headers @response_headers end |
.root_tags ⇒ Object
Returns the value of attribute root_tags.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def @root_tags end |
.security_schemes ⇒ Object
Returns the value of attribute security_schemes.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def security_schemes @security_schemes end |
.servers ⇒ Object
Returns the value of attribute servers.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def servers @servers end |
.summary_builder ⇒ Object
Returns the value of attribute summary_builder.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def summary_builder @summary_builder end |
.tags_builder ⇒ Object
Returns the value of attribute tags_builder.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def @tags_builder end |
.title ⇒ Object
Returns the value of attribute title.
73 74 75 |
# File 'lib/rspec/openapi.rb', line 73 def title @title end |
Class Method Details
.json_schema_based? ⇒ Boolean
3.1+ drops nullable in favour of JSON Schema null types.
114 115 116 |
# File 'lib/rspec/openapi.rb', line 114 def json_schema_based? openapi_version_at_least?('3.1') end |
.openapi_version_at_least?(version) ⇒ Boolean
109 110 111 |
# File 'lib/rspec/openapi.rb', line 109 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.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rspec/openapi.rb', line 134 def register_http_methods(methods) # :nocov: # Guards users without Rails. Every job here installs it, so this arm is # unreachable from the suite. SimpleCov's token is `nocov`, so the marker # this used to carry never actually excluded anything. return unless defined?(ActionDispatch::Request::HTTP_METHODS) # :nocov: 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
128 129 130 |
# File 'lib/rspec/openapi.rb', line 128 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.
119 120 121 |
# File 'lib/rspec/openapi.rb', line 119 def supports_additional_operations? openapi_version_at_least?('3.2') end |
.supports_item_schema? ⇒ Boolean
3.2 adds itemSchema for sequential (streaming) media types.
124 125 126 |
# File 'lib/rspec/openapi.rb', line 124 def supports_item_schema? openapi_version_at_least?('3.2') end |