forked from loafle/openapi-generator-original
* Rename templateDir: rails5 -> ruby-on-rails-server * Rename script: rails5-petstore-server.sh -> ruby-on-rails-server-petstore.sh * Rename sample folder: rails5 -> ruby-on-rails * Rename script(openapi3): rails5-petstore-server.sh -> ruby-on-rails-server-petstore.sh * Update ruby-on-rails-server-petstore.sh * Rename templateDir: sinatra -> ruby-sinatra-server * Rename script: sinatra-petstore-server.sh -> ruby-sinatra-server-petstore.sh * Rename sample folder: sinatra -> ruby-sinatra * Update script * Rename templateDir: ruby -> ruby-client * Rename script: ruby-petstore.sh -> ruby-client-petstore.sh * Update scripts * Update samples - bin/ruby-sinatra-server-petstore.sh - bin/ruby-on-rails-server-petstore.sh - bin/ruby-client-petstore.sh - bin/security/ruby-client-petstore.sh
187 lines
4.4 KiB
Ruby
187 lines
4.4 KiB
Ruby
require 'json'
|
|
|
|
|
|
MyApp.add_route('POST', '/v2/user', {
|
|
"resourcePath" => "/User",
|
|
"summary" => "Create user",
|
|
"nickname" => "create_user",
|
|
"responseClass" => "void",
|
|
"endpoint" => "/user",
|
|
"notes" => "This can only be done by the logged in user.",
|
|
"parameters" => [
|
|
{
|
|
"name" => "body",
|
|
"description" => "Created user object",
|
|
"dataType" => "User",
|
|
"paramType" => "body",
|
|
}
|
|
]}) do
|
|
cross_origin
|
|
# the guts live here
|
|
|
|
{"message" => "yes, it worked"}.to_json
|
|
end
|
|
|
|
|
|
MyApp.add_route('POST', '/v2/user/createWithArray', {
|
|
"resourcePath" => "/User",
|
|
"summary" => "Creates list of users with given input array",
|
|
"nickname" => "create_users_with_array_input",
|
|
"responseClass" => "void",
|
|
"endpoint" => "/user/createWithArray",
|
|
"notes" => "",
|
|
"parameters" => [
|
|
{
|
|
"name" => "body",
|
|
"description" => "List of user object",
|
|
"dataType" => "array[User]",
|
|
"paramType" => "body",
|
|
}
|
|
]}) do
|
|
cross_origin
|
|
# the guts live here
|
|
|
|
{"message" => "yes, it worked"}.to_json
|
|
end
|
|
|
|
|
|
MyApp.add_route('POST', '/v2/user/createWithList', {
|
|
"resourcePath" => "/User",
|
|
"summary" => "Creates list of users with given input array",
|
|
"nickname" => "create_users_with_list_input",
|
|
"responseClass" => "void",
|
|
"endpoint" => "/user/createWithList",
|
|
"notes" => "",
|
|
"parameters" => [
|
|
{
|
|
"name" => "body",
|
|
"description" => "List of user object",
|
|
"dataType" => "array[User]",
|
|
"paramType" => "body",
|
|
}
|
|
]}) do
|
|
cross_origin
|
|
# the guts live here
|
|
|
|
{"message" => "yes, it worked"}.to_json
|
|
end
|
|
|
|
|
|
MyApp.add_route('DELETE', '/v2/user/{username}', {
|
|
"resourcePath" => "/User",
|
|
"summary" => "Delete user",
|
|
"nickname" => "delete_user",
|
|
"responseClass" => "void",
|
|
"endpoint" => "/user/{username}",
|
|
"notes" => "This can only be done by the logged in user.",
|
|
"parameters" => [
|
|
{
|
|
"name" => "username",
|
|
"description" => "The name that needs to be deleted",
|
|
"dataType" => "string",
|
|
"paramType" => "path",
|
|
},
|
|
]}) do
|
|
cross_origin
|
|
# the guts live here
|
|
|
|
{"message" => "yes, it worked"}.to_json
|
|
end
|
|
|
|
|
|
MyApp.add_route('GET', '/v2/user/{username}', {
|
|
"resourcePath" => "/User",
|
|
"summary" => "Get user by user name",
|
|
"nickname" => "get_user_by_name",
|
|
"responseClass" => "User",
|
|
"endpoint" => "/user/{username}",
|
|
"notes" => "",
|
|
"parameters" => [
|
|
{
|
|
"name" => "username",
|
|
"description" => "The name that needs to be fetched. Use user1 for testing.",
|
|
"dataType" => "string",
|
|
"paramType" => "path",
|
|
},
|
|
]}) do
|
|
cross_origin
|
|
# the guts live here
|
|
|
|
{"message" => "yes, it worked"}.to_json
|
|
end
|
|
|
|
|
|
MyApp.add_route('GET', '/v2/user/login', {
|
|
"resourcePath" => "/User",
|
|
"summary" => "Logs user into the system",
|
|
"nickname" => "login_user",
|
|
"responseClass" => "string",
|
|
"endpoint" => "/user/login",
|
|
"notes" => "",
|
|
"parameters" => [
|
|
{
|
|
"name" => "username",
|
|
"description" => "The user name for login",
|
|
"dataType" => "string",
|
|
"allowableValues" => "",
|
|
"paramType" => "query",
|
|
},
|
|
{
|
|
"name" => "password",
|
|
"description" => "The password for login in clear text",
|
|
"dataType" => "string",
|
|
"allowableValues" => "",
|
|
"paramType" => "query",
|
|
},
|
|
]}) do
|
|
cross_origin
|
|
# the guts live here
|
|
|
|
{"message" => "yes, it worked"}.to_json
|
|
end
|
|
|
|
|
|
MyApp.add_route('GET', '/v2/user/logout', {
|
|
"resourcePath" => "/User",
|
|
"summary" => "Logs out current logged in user session",
|
|
"nickname" => "logout_user",
|
|
"responseClass" => "void",
|
|
"endpoint" => "/user/logout",
|
|
"notes" => "",
|
|
"parameters" => [
|
|
]}) do
|
|
cross_origin
|
|
# the guts live here
|
|
|
|
{"message" => "yes, it worked"}.to_json
|
|
end
|
|
|
|
|
|
MyApp.add_route('PUT', '/v2/user/{username}', {
|
|
"resourcePath" => "/User",
|
|
"summary" => "Updated user",
|
|
"nickname" => "update_user",
|
|
"responseClass" => "void",
|
|
"endpoint" => "/user/{username}",
|
|
"notes" => "This can only be done by the logged in user.",
|
|
"parameters" => [
|
|
{
|
|
"name" => "username",
|
|
"description" => "name that need to be deleted",
|
|
"dataType" => "string",
|
|
"paramType" => "path",
|
|
},
|
|
{
|
|
"name" => "body",
|
|
"description" => "Updated user object",
|
|
"dataType" => "User",
|
|
"paramType" => "body",
|
|
}
|
|
]}) do
|
|
cross_origin
|
|
# the guts live here
|
|
|
|
{"message" => "yes, it worked"}.to_json
|
|
end
|
|
|