mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 10:46:09 +00:00
change better method call
This commit is contained in:
@@ -2,28 +2,14 @@ Rails.application.routes.draw do
|
||||
|
||||
def add_swagger_route http_method, path, opts = {}
|
||||
full_path = path.gsub(/{(.*?)}/, ':\1')
|
||||
action =
|
||||
(opts[:isRestfulIndex] && :index) ||
|
||||
(opts[:isRestfulShow] && :show) ||
|
||||
(opts[:isRestfulCreate] && :create) ||
|
||||
(opts[:isRestfulUpdate] && :update) ||
|
||||
(opts[:isRestfulDestroy] && :destroy) ||
|
||||
opts[:nickname]
|
||||
|
||||
match full_path, to: "#{opts.fetch(:classVarName)}##{action}", via: http_method
|
||||
match full_path, to: "#{opts.fetch(:controller_name)}##{opts[:action_name]}", via: http_method
|
||||
end
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
add_swagger_route '{{httpMethod}}', '{{basePathWithoutHost}}{{path}}',
|
||||
classVarName: '{{classVarName}}', nickname: '{{nickname}}',
|
||||
isRestfulIndex: {{#isRestfulIndex}}true{{/isRestfulIndex}}{{^isRestfulIndex}}false{{/isRestfulIndex}},
|
||||
isRestfulCreate: {{#isRestfulCreate}}true{{/isRestfulCreate}}{{^isRestfulCreate}}false{{/isRestfulCreate}},
|
||||
isRestfulUpdate: {{#isRestfulUpdate}}true{{/isRestfulUpdate}}{{^isRestfulUpdate}}false{{/isRestfulUpdate}},
|
||||
isRestfulShow: {{#isRestfulShow}}true{{/isRestfulShow}}{{^isRestfulShow}}false{{/isRestfulShow}},
|
||||
isRestfulDestroy: {{#isRestfulDestroy}}true{{/isRestfulDestroy}}{{^isRestfulDestroy}}false{{/isRestfulDestroy}}
|
||||
add_swagger_route '{{httpMethod}}', '{{basePathWithoutHost}}{{path}}', controller_name: '{{classVarName}}', action_name: {{#isRestfulIndex}}'index'{{/isRestfulIndex}}{{#isRestfulCreate}}'create'{{/isRestfulCreate}}{{#isRestfulUpdate}}'update'{{/isRestfulUpdate}}{{#isRestfulShow}}'show'{{/isRestfulShow}}{{#isRestfulDestroy}}'destroy'{{/isRestfulDestroy}}{{^isRestful}}'{{nickname}}'{{/isRestful}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
|
||||
Reference in New Issue
Block a user