Open erictuvesson opened 4 years ago
This block of code is where identifiers are handled by the parser.
https://github.com/livingsocial/swagger_yard/blob/master/lib/swagger_yard/type_parser.rb#L70-L75
Looks like you could monkeypatch the SwaggerYard::Model.mangle
method and add your custom behaviors:
class SwaggerYard::Model
def self.mangle(name)
case name
when /Integer/
name.downcase
else
name.gsub(/[^[:alnum:]_]+/, '_')
end
end
end
If you want to submit a patch to add some more formalized custom type mapping, feel free to submit a PR.
Thanks for the quick reply.
I would love to do a PR, just I don't have the time for it 😞
I ended up adding this monkeypatch, maybe I will add more types later. I only found an issue with String and Integer
types now.
module SwaggerYard
class Model
def self.mangle(name)
case name
when /string/i then name.downcase
when /integer/i then name.downcase
else
name.gsub(/[^[:alnum:]_]+/, '_')
end
end
end
end
Hey,
I currently came across an issue where we annotate the code with uppercase "Integer", but Swagger only supports lowercase
integer
. https://swagger.io/docs/specification/data-models/data-types/Is there a way to force it to be lowercase or have a way to convert types to a different name?
It could be nice to have a hash where you can map to custom types.
Something like this maybe