Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This release has no stricter or less strict request validation. It changes mostly internal stuff and adds a Sinatra integration. It's a major version, but it should be safe to upgrade.
Breaking changes
multipart/form-datapart that was sent as a file was read into memory, which allowed a single large upload to any documented multipart route to exhaust the memory of the server process. Such a field is now passed through as Rack parsed it ({ filename:, type:, name:, tempfile:, head: }), which is the same shape that Sinatra and Hanami hand to your application. Useparsed_body['file'][:tempfile]to read or stream the file.minLength,maxLengthorpatternon a field that was sent as a file are ignored.after_request_body_property_validationhook sees an empty String instead of the file.contentTypein theencodingmap, are read and validated as before.openapi_parametersgem was merged into openapi_first and is not a dependency anymore. Parameter parsing now lives in openapi_first itself. If you registered a parser for parameters that use acontentfield, useOpenapiFirst::ParameterContentParsers.registerinstead ofOpenapiParameters::ContentParsers.register.OpenapiFirst::ResponseHeader(returned byResponse#headers, renamed fromOpenapiFirst::Header) exposesparameter, anOpenapiFirst::Parameter, instead ofnode.OpenapiFirst::Request#parametersreturns the parameters that are defined for a request asOpenapiFirst::Parameterobjects, which exposename,location,schema,required?,deprecated?,style,explode?andmedia_type.Removed deprecations
OpenapiFirst::Configuration#request_validation_raise_errorand#response_validation_raise_error(both reader and writer), deprecated since 3.0.0. Passraise_error:to middlewares instead.OpenapiFirst::Test::Configuration#coverage_formatter,#coverage_formatter=,#coverage_formatter_optionsand#coverage_formatter_options=, deprecated since 3.4.0. Use#coverage_reporter/#coverage_reporter_optionsinstead.OpenapiFirst::Test::Coverage::TerminalFormatter, deprecated since 3.4.0. UseOpenapiFirst::Test::Coverage::TerminalReporterinstead.formatter:keyword ofOpenapiFirst::Test.report_coverage, deprecated since 3.4.0. Usereporter:instead.OpenapiFirst::Test::Coverage::TerminalReporter#format, deprecated since 3.4.0. Use#reportinstead.Added
Added: API coverage now reports skipped requests and responses.
Added: OpenAPI 3.2 documents are accepted, but not fully supported yet. They are handled using the OpenAPI 3.1 rules, so features introduced in 3.2 may be ignored. Loading such a document prints a warning. Operations defined under
additionalOperationsare routed. See #469.Added: Show all covered endpoints in HTML coverage reporter and filter covered/uncovered endpoints.
Added: Sinatra integration (OpenapiFirst::Sinatra)
A Sinatra extension to define routes by referencing OpenAPI operations:
The HTTP method and path for each route come from the operationId.
Request validation is called automatically for these operations.
Fixed
ArgumentErrorin OpenAPI 3.0 documents when a top-level key of that file collides with a JSON Schema keyword, such as$ref: 'parameters.yaml#/id'. The containing file is no longer parsed as a schema itself, so such keys work like any other now. See #348.$refs nested inside the schema of a parameter or a response header are resolved now, so these values are unpacked and converted as described. Before, only a$refat the top level of the schema was resolved. See deepObject paramters with array values do not support nested $refs #450.contentfield with a$ref'd schema is resolved now.NoMethodErrorwhen a parameter has neitherschemanorcontent.content(?filter=a&filter=b) raised aNoMethodErrororTypeError. The values are validated against the schema now, which returns an:invalid_queryfailure.style: matrixraised aNoMethodErrorif its value did not contain the parameter name, or contained it more than once. Such values are parsed like theirexplodecounterpart now.style: matrix, or a path parameter that describes an object, raised anArgumentErrorif its value had an invalid%-encoding. Such values are validated against the schema now.contentfield with a value that could not be parsed as that media type (e.g.007asapplication/json) was converted using the parameter's schema type anyway, which could make an invalid value pass schema validation (e.g. as the integer7). Such values are left as they are now, so schema validation rejects them as before.Definition. Response headers with a schema no longer keep the whole raw document node alive, and a couple of build-time-only hashes were replaced with more compact structures.