Skip to content

Commit

Permalink
fix(open_api): required should be nil or true
Browse files Browse the repository at this point in the history
the openapi spec says required should only be present if true
  • Loading branch information
stakach committed Feb 13, 2025
1 parent 8174d5b commit 2661952
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: action-controller
version: 7.5.2
version: 7.5.3
crystal: ">= 1.9.0"

dependencies:
Expand Down
10 changes: 5 additions & 5 deletions src/action-controller/open_api.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ActionController::OpenAPI
alias Params = NamedTuple(
name: String,
in: Symbol,
required: Bool,
required: Bool?,
schema: String,
docs: String?,
example: String?,
Expand Down Expand Up @@ -300,7 +300,7 @@ module ActionController::OpenAPI
{
name: {{ param_name }},
in: {{ param[:in] }},
required: {{ param[:required] }},
required: ({{ param[:required] ? true : nil }}).as(Bool?),
schema: ::JSON::Schema.introspect({{ param[:schema] }}, openapi: true).to_json,
docs: {{ param[:docs] }}.as(String?),
example: {{ param[:example] }}.as(String?),
Expand Down Expand Up @@ -350,7 +350,7 @@ module ActionController::OpenAPI
{
name: {{ param[:header] || param_name }},
in: {{ param[:in] }},
required: {{ param[:required] }},
required: ({{ param[:required] ? true : nil }}).as(Bool?),
schema: ::JSON::Schema.introspect({{ param[:schema] }}, openapi: true).to_json,
docs: {{ param[:docs] }}.as(String?),
example: {{ param[:example] }}.as(String?),
Expand Down Expand Up @@ -473,7 +473,7 @@ module ActionController::OpenAPI
param = Parameter.new
param.name = raw_param[:name]
param.in = raw_param[:in].to_s
param.required = raw_param[:required]
param.required = raw_param[:required] ? true : nil
param.schema = JSON.parse(raw_param[:schema])
param.description = raw_param[:docs]
param.example = raw_param[:example]
Expand Down Expand Up @@ -503,7 +503,7 @@ module ActionController::OpenAPI
param = Parameter.new
param.name = param_name
param.in = raw_param[:in].to_s
param.required = raw_param[:required]
param.required = raw_param[:required] ? true : nil
param.schema = JSON.parse(raw_param[:schema])
param.description = raw_param[:docs]
param.example = raw_param[:example]
Expand Down

0 comments on commit 2661952

Please sign in to comment.