[crystal][client] some fix and minor improvement (#9416)

* [crystal][client] remove redundant include JSON::Serializable

* [crystal][client] fix syntax error

* [crystal][client] fix shard name

* [crystal][client] add 'require "json"'

* [crystal][client] update sample projects
This commit is contained in:
Yusuke Hosonuma 2021-05-10 17:17:49 +09:00 committed by GitHub
parent ae2423e64a
commit 1751aa7272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 74 additions and 80 deletions

View File

@ -197,7 +197,10 @@ module {{moduleName}}
# Returns Auth Settings hash for api client. # Returns Auth Settings hash for api client.
def auth_settings def auth_settings
Hash{ {{#authMethods}}{{#isApiKey}}"{{name}}" => { Hash{
{{#authMethods}}
{{#isApiKey}}
"{{name}}" => {
type: "api_key", type: "api_key",
in: {{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}, in: {{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}},
key: "{{keyParamName}}", key: "{{keyParamName}}",
@ -206,8 +209,7 @@ module {{moduleName}}
{{/isApiKey}} {{/isApiKey}}
{{#isBasic}} {{#isBasic}}
{{#isBasicBasic}} {{#isBasicBasic}}
"{{name}}" => "{{name}}" => {
{
type: "basic", type: "basic",
in: "header", in: "header",
key: "Authorization", key: "Authorization",
@ -215,8 +217,7 @@ module {{moduleName}}
}, },
{{/isBasicBasic}} {{/isBasicBasic}}
{{#isBasicBearer}} {{#isBasicBearer}}
"{{name}}" => "{{name}}" => {
{
type: "bearer", type: "bearer",
in: "header", in: "header",
{{#bearerFormat}} {{#bearerFormat}}
@ -228,8 +229,7 @@ module {{moduleName}}
{{/isBasicBearer}} {{/isBasicBearer}}
{{/isBasic}} {{/isBasic}}
{{#isOAuth}} {{#isOAuth}}
"{{name}}" => "{{name}}" => {
{
type: "oauth2", type: "oauth2",
in: "header", in: "header",
key: "Authorization", key: "Authorization",

View File

@ -1,5 +1,6 @@
# {{#lambdaPrefixWithHash}}{{> api_info}}{{/lambdaPrefixWithHash}} # {{#lambdaPrefixWithHash}}{{> api_info}}{{/lambdaPrefixWithHash}}
require "json"
require "time" require "time"
module {{moduleName}} module {{moduleName}}

View File

@ -1,8 +1,10 @@
{{#description}} {{#description}}
# {{{description}}} # {{{description}}}
{{/description}} {{/description}}
class {{classname}}{{#parent}} < {{{.}}}{{/parent}} include JSON::Serializable class {{classname}}{{#parent}} < {{{.}}}{{/parent}}
include JSON::Serializable {{#vars}} include JSON::Serializable
{{#vars}}
{{#description}} {{#description}}
# {{{description}}} # {{{description}}}
{{/description}} {{/description}}

View File

@ -1,4 +1,4 @@
name: {{{moduleName}}} name: {{{shardName}}}
version: {{{shardVersion}}} version: {{{shardVersion}}}
authors: authors:
- {{{shardAuthors}}} - {{{shardAuthors}}}

View File

@ -1,4 +1,4 @@
name: Petstore name: petstore
version: 1.0.0 version: 1.0.0
authors: authors:
- -

View File

@ -205,14 +205,14 @@ module Petstore
# Returns Auth Settings hash for api client. # Returns Auth Settings hash for api client.
def auth_settings def auth_settings
Hash{ "api_key" => { Hash{
"api_key" => {
type: "api_key", type: "api_key",
in: "header", in: "header",
key: "api_key", key: "api_key",
value: api_key_with_prefix("api_key") value: api_key_with_prefix("api_key")
}, },
"petstore_auth" => "petstore_auth" => {
{
type: "oauth2", type: "oauth2",
in: "header", in: "header",
key: "Authorization", key: "Authorization",

View File

@ -8,20 +8,20 @@
#OpenAPI Generator version: 5.2.0-SNAPSHOT #OpenAPI Generator version: 5.2.0-SNAPSHOT
# #
require "json"
require "time" require "time"
module Petstore module Petstore
# Describes the result of uploading an image resource # Describes the result of uploading an image resource
class ApiResponse include JSON::Serializable class ApiResponse
include JSON::Serializable include JSON::Serializable
@[JSON::Field(key: code, type: Int32)] @[JSON::Field(key: code, type: Int32)]
property code : Int32 property code : Int32
@[JSON::Field(key: type, type: String)] @[JSON::Field(key: type, type: String)]
property _type : String property _type : String
@[JSON::Field(key: message, type: String)] @[JSON::Field(key: message, type: String)]
property message : String property message : String

View File

@ -8,16 +8,17 @@
#OpenAPI Generator version: 5.2.0-SNAPSHOT #OpenAPI Generator version: 5.2.0-SNAPSHOT
# #
require "json"
require "time" require "time"
module Petstore module Petstore
# A category for a pet # A category for a pet
class Category include JSON::Serializable class Category
include JSON::Serializable include JSON::Serializable
@[JSON::Field(key: id, type: Int64)] @[JSON::Field(key: id, type: Int64)]
property id : Int64 property id : Int64
@[JSON::Field(key: name, type: String)] @[JSON::Field(key: name, type: String)]
property name : String property name : String

View File

@ -8,33 +8,30 @@
#OpenAPI Generator version: 5.2.0-SNAPSHOT #OpenAPI Generator version: 5.2.0-SNAPSHOT
# #
require "json"
require "time" require "time"
module Petstore module Petstore
# An order for a pets from the pet store # An order for a pets from the pet store
class Order include JSON::Serializable class Order
include JSON::Serializable include JSON::Serializable
@[JSON::Field(key: id, type: Int64)] @[JSON::Field(key: id, type: Int64)]
property id : Int64 property id : Int64
@[JSON::Field(key: petId, type: Int64)] @[JSON::Field(key: petId, type: Int64)]
property pet_id : Int64 property pet_id : Int64
@[JSON::Field(key: quantity, type: Int32)] @[JSON::Field(key: quantity, type: Int32)]
property quantity : Int32 property quantity : Int32
@[JSON::Field(key: shipDate, type: Time)] @[JSON::Field(key: shipDate, type: Time)]
property ship_date : Time property ship_date : Time
# Order Status # Order Status
@[JSON::Field(key: status, type: String)] @[JSON::Field(key: status, type: String)]
property status : String property status : String
@[JSON::Field(key: complete, type: Bool)] @[JSON::Field(key: complete, type: Bool)]
property complete : Bool property complete : Bool

View File

@ -8,32 +8,29 @@
#OpenAPI Generator version: 5.2.0-SNAPSHOT #OpenAPI Generator version: 5.2.0-SNAPSHOT
# #
require "json"
require "time" require "time"
module Petstore module Petstore
# A pet for sale in the pet store # A pet for sale in the pet store
class Pet include JSON::Serializable class Pet
include JSON::Serializable include JSON::Serializable
@[JSON::Field(key: id, type: Int64)] @[JSON::Field(key: id, type: Int64)]
property id : Int64 property id : Int64
@[JSON::Field(key: category, type: Category)] @[JSON::Field(key: category, type: Category)]
property category : Category property category : Category
@[JSON::Field(key: name, type: String)] @[JSON::Field(key: name, type: String)]
property name : String property name : String
@[JSON::Field(key: photoUrls, type: Array(String))] @[JSON::Field(key: photoUrls, type: Array(String))]
property photo_urls : Array(String) property photo_urls : Array(String)
@[JSON::Field(key: tags, type: Array(Tag))] @[JSON::Field(key: tags, type: Array(Tag))]
property tags : Array(Tag) property tags : Array(Tag)
# pet status in the store # pet status in the store
@[JSON::Field(key: status, type: String)] @[JSON::Field(key: status, type: String)]
property status : String property status : String

View File

@ -8,16 +8,17 @@
#OpenAPI Generator version: 5.2.0-SNAPSHOT #OpenAPI Generator version: 5.2.0-SNAPSHOT
# #
require "json"
require "time" require "time"
module Petstore module Petstore
# A tag for a pet # A tag for a pet
class Tag include JSON::Serializable class Tag
include JSON::Serializable include JSON::Serializable
@[JSON::Field(key: id, type: Int64)] @[JSON::Field(key: id, type: Int64)]
property id : Int64 property id : Int64
@[JSON::Field(key: name, type: String)] @[JSON::Field(key: name, type: String)]
property name : String property name : String

View File

@ -8,40 +8,35 @@
#OpenAPI Generator version: 5.2.0-SNAPSHOT #OpenAPI Generator version: 5.2.0-SNAPSHOT
# #
require "json"
require "time" require "time"
module Petstore module Petstore
# A User who is purchasing from the pet store # A User who is purchasing from the pet store
class User include JSON::Serializable class User
include JSON::Serializable include JSON::Serializable
@[JSON::Field(key: id, type: Int64)] @[JSON::Field(key: id, type: Int64)]
property id : Int64 property id : Int64
@[JSON::Field(key: username, type: String)] @[JSON::Field(key: username, type: String)]
property username : String property username : String
@[JSON::Field(key: firstName, type: String)] @[JSON::Field(key: firstName, type: String)]
property first_name : String property first_name : String
@[JSON::Field(key: lastName, type: String)] @[JSON::Field(key: lastName, type: String)]
property last_name : String property last_name : String
@[JSON::Field(key: email, type: String)] @[JSON::Field(key: email, type: String)]
property email : String property email : String
@[JSON::Field(key: password, type: String)] @[JSON::Field(key: password, type: String)]
property password : String property password : String
@[JSON::Field(key: phone, type: String)] @[JSON::Field(key: phone, type: String)]
property phone : String property phone : String
# User Status # User Status
@[JSON::Field(key: userStatus, type: Int32)] @[JSON::Field(key: userStatus, type: Int32)]
property user_status : Int32 property user_status : Int32