Skip to content

Commit

Permalink
Set content and required keyword dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov committed Jan 10, 2024
1 parent 2da945a commit def1e34
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning].

## [Unreleased]

### Fixed

- Fix `Skooma::Error: Missing name key /request` by setting `content` and `required` keyword dependencies. ([@skryukov])

## [0.2.2] - 2024-01-04

### Added
Expand Down
1 change: 1 addition & 0 deletions lib/skooma/objects/parameter/keywords/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Content < Header::Keywords::Content
self.key = "content"
self.value_schema = :object_of_schemas
self.schema_value_class = Objects::MediaType
self.depends_on = %w[in name style explode allowReserved allowEmptyValue]

def evaluate(instance, result)
return if instance.value.nil?
Expand Down
1 change: 1 addition & 0 deletions lib/skooma/objects/parameter/keywords/required.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Parameter
module Keywords
class Required < JSONSkooma::Keywords::Base
self.key = "required"
self.depends_on = %w[in name style explode allowReserved allowEmptyValue]

def evaluate(instance, result)
if json.value && ValueParser.call(instance, result)&.value.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/skooma/objects/parameter/keywords/value_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def call(instance, result)
raise Error, "Missing `in` key #{result.path}" unless type

key = result.sibling(instance, "name")&.annotation
raise Error, "Missing `name` key #{instance.path}: #{key}" unless key
raise Error, "Missing `name` key #{result.path}" unless key

case type
when "query"
Expand Down
7 changes: 4 additions & 3 deletions spec/openapi_test_suite/query_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@
"parameters": [
{
"in": "query",
"name": "foo",
"required": true,
"name": "foo",
"schema": {
"type": "string",
"minLength": 3
}
},
{
"in": "query",
"name": "bar",
"required": false,
"content": {
"application/json": {
"schema": {
"type": "string",
"minLength": 3
}
}
}
},
"name": "bar"
}
],
"responses": {
Expand Down

0 comments on commit def1e34

Please sign in to comment.