Skip to content

Commit

Permalink
Fix schemas for nullable properties
Browse files Browse the repository at this point in the history
Fix incorrect handling of schemas for nullable properties.
Resolves domaindrivendev#3013.
  • Loading branch information
martincostello committed Aug 8, 2024
1 parent b7161e6 commit 581ac15
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public DataContract GetDataContractForType(Type type)

return DataContract.ForObject(
underlyingType: effectiveType,
properties: GetDataPropertiesFor(type, out Type extensionDataType),
properties: GetDataPropertiesFor(effectiveType, out Type extensionDataType),
extensionDataType: extensionDataType,
jsonConverter: (value) => JsonConverterFunc(value, effectiveType));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,36 @@
x-purpose: test
}
},
/Issue3013/Get: {
get: {
tags: [
Issue3013
],
responses: {
200: {
description: OK,
content: {
text/plain: {
schema: {
$ref: #/components/schemas/TestResponse
}
},
application/json: {
schema: {
$ref: #/components/schemas/TestResponse
}
},
text/json: {
schema: {
$ref: #/components/schemas/TestResponse
}
}
}
}
},
x-purpose: test
}
},
/promotions: {
get: {
tags: [
Expand Down Expand Up @@ -1381,6 +1411,29 @@
},
additionalProperties: false
},
TestResponse: {
type: object,
properties: {
foo: {
$ref: #/components/schemas/TestStruct
}
},
additionalProperties: false
},
TestStruct: {
type: object,
properties: {
a: {
type: integer,
format: int32
},
b: {
type: integer,
format: int32
}
},
additionalProperties: false
},
Transaction: {
required: [
amount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,36 @@
x-purpose: test
}
},
/Issue3013/Get: {
get: {
tags: [
Issue3013
],
responses: {
200: {
description: OK,
content: {
text/plain: {
schema: {
$ref: #/components/schemas/TestResponse
}
},
application/json: {
schema: {
$ref: #/components/schemas/TestResponse
}
},
text/json: {
schema: {
$ref: #/components/schemas/TestResponse
}
}
}
}
},
x-purpose: test
}
},
/promotions: {
get: {
tags: [
Expand Down Expand Up @@ -1381,6 +1411,29 @@
},
additionalProperties: false
},
TestResponse: {
type: object,
properties: {
foo: {
$ref: #/components/schemas/TestStruct
}
},
additionalProperties: false
},
TestStruct: {
type: object,
properties: {
a: {
type: integer,
format: int32
},
b: {
type: integer,
format: int32
}
},
additionalProperties: false
},
Transaction: {
required: [
amount
Expand Down

0 comments on commit 581ac15

Please sign in to comment.