Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -524,31 +524,31 @@ private static OpenApiSchema CreateScalarSchema(IScalarTypeDefinition scalarType

private static string? GetJsonSchemaFormat(IScalarTypeDefinition scalarType)
{
var format = scalarType.SpecifiedBy?.OriginalString switch
var format = scalarType.Name switch
{
"https://scalars.graphql.org/chillicream/date.html" => "date",
SpecScalarNames.Float.Name => "double",
SpecScalarNames.Int.Name => "int32",
_ => null
};

return format ?? scalarType.SpecifiedBy?.OriginalString switch
{
"https://scalars.graphql.org/chillicream/byte.html" => "int8",
"https://scalars.graphql.org/chillicream/date-time.html" => "date-time",
"https://scalars.graphql.org/chillicream/date.html" => "date",
"https://scalars.graphql.org/chillicream/duration.html" => "duration",
"https://scalars.graphql.org/chillicream/local-date.html" => "date",
"https://scalars.graphql.org/chillicream/uuid.html" => "uuid",
"https://scalars.graphql.org/chillicream/long.html" => "int64",
"https://scalars.graphql.org/chillicream/short.html" => "int16",
"https://scalars.graphql.org/chillicream/unsigned-byte.html" => "uint8",
"https://scalars.graphql.org/chillicream/unsigned-int.html" => "uint32",
"https://scalars.graphql.org/chillicream/unsigned-long.html" => "uint64",
"https://scalars.graphql.org/chillicream/unsigned-short.html" => "uint16",
"https://scalars.graphql.org/chillicream/uri.html" => "uri",
"https://scalars.graphql.org/chillicream/url.html" => "uri",
"https://scalars.graphql.org/chillicream/uuid.html" => "uuid",
_ => null
};

if (format is null)
{
var serializationType = scalarType.GetScalarSerializationType();

return serializationType switch
{
ScalarSerializationType.Int => "int32",
ScalarSerializationType.Float => "float",
_ => null
};
}

return format;
}

private static string? GetJsonSchemaPattern(IScalarTypeDefinition scalarType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ public async Task Http_Post_Complex_Object()
"short": 1,
"string": "test",
"unknown": "test",
"unsignedByte": 1,
"unsignedInt": 65536,
"unsignedLong": 4294967296,
"unsignedShort": 256,
"uri": "https://example.com/",
"url": "https://example.com/",
"uuid": "00000000-0000-0000-0000-000000000000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
"short",
"string",
"unknown",
"unsignedByte",
"unsignedInt",
"unsignedLong",
"unsignedShort",
"uri",
"url",
"uuid"
Expand Down Expand Up @@ -80,7 +84,7 @@
"byte": {
"type": "integer",
"description": "The `Byte` scalar type represents a signed 8-bit integer.",
"format": "int32"
"format": "int8"
},
"date": {
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
Expand All @@ -96,8 +100,7 @@
},
"decimal": {
"type": "number",
"description": "The `Decimal` scalar type represents a decimal floating-point number with high precision.",
"format": "float"
"description": "The `Decimal` scalar type represents a decimal floating-point number with high precision."
},
"duration": {
"pattern": "^-?P(?:\\d+W|(?=\\d|T(?:\\d|$))(?:\\d+Y)?(?:\\d+M)?(?:\\d+D)?(?:T(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:\\.\\d+)?S)?)?)$",
Expand All @@ -114,7 +117,7 @@
},
"float": {
"type": "number",
"format": "float"
"format": "double"
},
"id": {
"oneOf": [
Expand Down Expand Up @@ -178,7 +181,7 @@
"long": {
"type": "integer",
"description": "The `Long` scalar type represents a signed 64-bit integer.",
"format": "int32"
"format": "int64"
},
"object": {
"required": [
Expand Down Expand Up @@ -214,14 +217,34 @@
"short": {
"type": "integer",
"description": "The `Short` scalar type represents a signed 16-bit integer.",
"format": "int32"
"format": "int16"
},
"string": {
"type": "string"
},
"unknown": {
"type": "string"
},
"unsignedByte": {
"type": "integer",
"description": "The `UnsignedByte` scalar type represents an unsigned 8-bit integer.",
"format": "uint8"
},
"unsignedInt": {
"type": "integer",
"description": "The `UnsignedInt` scalar type represents an unsigned 32-bit integer.",
"format": "uint32"
},
"unsignedLong": {
"type": "integer",
"description": "The `UnsignedLong` scalar type represents an unsigned 64-bit integer.",
"format": "uint64"
},
"unsignedShort": {
"type": "integer",
"description": "The `UnsignedShort` scalar type represents an unsigned 16-bit integer.",
"format": "uint16"
},
"uri": {
"type": "string",
"description": "The `URI` scalar type represents a Uniform Resource Identifier (URI) as defined by RFC 3986.",
Expand Down Expand Up @@ -321,7 +344,7 @@
"integer"
],
"description": "The `Byte` scalar type represents a signed 8-bit integer.",
"format": "int32"
"format": "int8"
},
"date": {
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
Expand All @@ -346,8 +369,7 @@
"null",
"number"
],
"description": "The `Decimal` scalar type represents a decimal floating-point number with high precision.",
"format": "float"
"description": "The `Decimal` scalar type represents a decimal floating-point number with high precision."
},
"duration": {
"pattern": "^-?P(?:\\d+W|(?=\\d|T(?:\\d|$))(?:\\d+Y)?(?:\\d+M)?(?:\\d+D)?(?:T(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:\\.\\d+)?S)?)?)$",
Expand All @@ -373,7 +395,7 @@
"null",
"number"
],
"format": "float"
"format": "double"
},
"id": {
"oneOf": [
Expand Down Expand Up @@ -458,7 +480,7 @@
"integer"
],
"description": "The `Long` scalar type represents a signed 64-bit integer.",
"format": "int32"
"format": "int64"
},
"object": {
"required": [
Expand Down Expand Up @@ -507,7 +529,7 @@
"integer"
],
"description": "The `Short` scalar type represents a signed 16-bit integer.",
"format": "int32"
"format": "int16"
},
"string": {
"type": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
"short",
"string",
"unknown",
"unsignedByte",
"unsignedInt",
"unsignedLong",
"unsignedShort",
"uri",
"url",
"uuid"
Expand Down Expand Up @@ -80,7 +84,7 @@
"byte": {
"type": "integer",
"description": "The `Byte` scalar type represents a signed 8-bit integer.",
"format": "int32"
"format": "int8"
},
"date": {
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
Expand All @@ -96,8 +100,7 @@
},
"decimal": {
"type": "number",
"description": "The `Decimal` scalar type represents a decimal floating-point number with high precision.",
"format": "float"
"description": "The `Decimal` scalar type represents a decimal floating-point number with high precision."
},
"duration": {
"pattern": "^-?P(?:\\d+W|(?=\\d|T(?:\\d|$))(?:\\d+Y)?(?:\\d+M)?(?:\\d+D)?(?:T(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:\\.\\d+)?S)?)?)$",
Expand All @@ -114,7 +117,7 @@
},
"float": {
"type": "number",
"format": "float"
"format": "double"
},
"id": {
"oneOf": [
Expand Down Expand Up @@ -178,7 +181,7 @@
"long": {
"type": "integer",
"description": "The `Long` scalar type represents a signed 64-bit integer.",
"format": "int32"
"format": "int64"
},
"object": {
"required": [
Expand Down Expand Up @@ -214,14 +217,34 @@
"short": {
"type": "integer",
"description": "The `Short` scalar type represents a signed 16-bit integer.",
"format": "int32"
"format": "int16"
},
"string": {
"type": "string"
},
"unknown": {
"type": "string"
},
"unsignedByte": {
"type": "integer",
"description": "The `UnsignedByte` scalar type represents an unsigned 8-bit integer.",
"format": "uint8"
},
"unsignedInt": {
"type": "integer",
"description": "The `UnsignedInt` scalar type represents an unsigned 32-bit integer.",
"format": "uint32"
},
"unsignedLong": {
"type": "integer",
"description": "The `UnsignedLong` scalar type represents an unsigned 64-bit integer.",
"format": "uint64"
},
"unsignedShort": {
"type": "integer",
"description": "The `UnsignedShort` scalar type represents an unsigned 16-bit integer.",
"format": "uint16"
},
"uri": {
"type": "string",
"description": "The `URI` scalar type represents a Uniform Resource Identifier (URI) as defined by RFC 3986.",
Expand Down Expand Up @@ -321,7 +344,7 @@
"integer"
],
"description": "The `Byte` scalar type represents a signed 8-bit integer.",
"format": "int32"
"format": "int8"
},
"date": {
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
Expand All @@ -346,8 +369,7 @@
"null",
"number"
],
"description": "The `Decimal` scalar type represents a decimal floating-point number with high precision.",
"format": "float"
"description": "The `Decimal` scalar type represents a decimal floating-point number with high precision."
},
"duration": {
"pattern": "^-?P(?:\\d+W|(?=\\d|T(?:\\d|$))(?:\\d+Y)?(?:\\d+M)?(?:\\d+D)?(?:T(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:\\.\\d+)?S)?)?)$",
Expand All @@ -373,7 +395,7 @@
"null",
"number"
],
"format": "float"
"format": "double"
},
"id": {
"oneOf": [
Expand Down Expand Up @@ -458,7 +480,7 @@
"integer"
],
"description": "The `Long` scalar type represents a signed 64-bit integer.",
"format": "int32"
"format": "int64"
},
"object": {
"required": [
Expand Down Expand Up @@ -507,7 +529,7 @@
"integer"
],
"description": "The `Short` scalar type represents a signed 16-bit integer.",
"format": "int32"
"format": "int16"
},
"string": {
"type": [
Expand Down
Loading
Loading