mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-22 22:06:43 +00:00
Fix invalid Swagger in YAML values
The original fix failed because though the Keys were now strings, some of the values for path variables were also symbols. Psych does have a safe_load which has a whitelist of classes but it does not have a safe_dump mode. We could have used deep_transform_values and manually converted the classes we did not want, but why risk a buggy implementation when JSON.generate works just fine?
This commit is contained in:
parent
2c0f3c9396
commit
eeb1026691
@ -48,15 +48,16 @@ module Rswag
|
||||
|
||||
def pretty_generate(doc)
|
||||
if @config.swagger_format == :yaml
|
||||
YAML.dump(doc.deep_stringify_keys)
|
||||
clean_doc = yaml_prepare(doc)
|
||||
YAML.dump(clean_doc)
|
||||
else # config errors are thrown in 'def swagger_format', no throw needed here
|
||||
JSON.pretty_generate(doc)
|
||||
end
|
||||
end
|
||||
|
||||
def deep_stringify_hash_keys(doc)
|
||||
|
||||
doc
|
||||
def yaml_prepare(doc)
|
||||
json_doc = JSON.pretty_generate(doc)
|
||||
clean_doc = JSON.parse(json_doc)
|
||||
end
|
||||
|
||||
def metadata_to_swagger(metadata)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user