Skip to content
Open
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 @@ -91,6 +91,10 @@ export class ExampleTypeFactory {
case "literal":
return FullExample.literal(schema.value);
case "nullable": {
// Explicit example of null should win over schema-level examples
if (example === null) {
return FullExample.null({});
}
if (
example == null &&
!this.hasExample(schema.value, 0, visitedSchemaIds, options) &&
Expand Down Expand Up @@ -474,7 +478,9 @@ export class ExampleTypeFactory {

const propertyExampleFromParent = fullExample[property];
const propertySchemaExample = this.getSchemaExample(schema.schema);
const exampleToUse = propertyExampleFromParent ?? propertySchemaExample;
// If the property is explicitly present in the example (even if null),
// treat that as authoritative; only fall back to schema example if it's absent.
const exampleToUse = inExample ? propertyExampleFromParent : propertySchemaExample;

const propertyExample = this.buildExampleHelper({
schema: schema.schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,7 @@
"type": "primitive"
},
"profileImageUrl": {
"value": {
"value": "profileImageUrl",
"type": "string"
},
"type": "primitive"
"type": "null"
},
"url": {
"value": {
Expand Down Expand Up @@ -1390,11 +1386,7 @@
"type": "primitive"
},
"profileImageUrl": {
"value": {
"value": "profileImageUrl",
"type": "string"
},
"type": "primitive"
"type": "null"
},
"url": {
"value": {
Expand Down Expand Up @@ -3334,11 +3326,7 @@
"type": "primitive"
},
"profileImageUrl": {
"value": {
"value": "profileImageUrl",
"type": "string"
},
"type": "primitive"
"type": "null"
},
"url": {
"value": {
Expand Down Expand Up @@ -4608,13 +4596,6 @@
"type": "double"
},
"type": "primitive"
},
"lastInsertRowid": {
"value": {
"value": "lastInsertRowid",
"type": "string"
},
"type": "primitive"
}
},
"type": "object"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ API endpoints",
"links": {
"self": "self",
},
"profileImageUrl": "profileImageUrl",
"profileImageUrl": null,
"url": "https://val.town/u/tmcw",
"username": "tmcw",
},
Expand Down Expand Up @@ -1303,7 +1303,7 @@ service:
id: 00000000-0000-0000-0000-000000000000
bio: Hello world
username: tmcw
profileImageUrl: profileImageUrl
profileImageUrl: null
url: https://val.town/u/tmcw
links:
self: self
Expand Down Expand Up @@ -2534,7 +2534,7 @@ give access to details and data from the requesting user.",
"links": {
"self": "self",
},
"profileImageUrl": "profileImageUrl",
"profileImageUrl": null,
"tier": "pro",
"url": "url",
"username": "tmcw",
Expand Down Expand Up @@ -3304,7 +3304,7 @@ service:
id: 00000000-0000-0000-0000-000000000000
bio: Hello world
username: tmcw
profileImageUrl: profileImageUrl
profileImageUrl: null
url: url
links:
self: self
Expand Down Expand Up @@ -3728,7 +3728,6 @@ docs: Search
"columns": [
"id",
],
"lastInsertRowid": "lastInsertRowid",
"rows": [
[
1,
Expand Down Expand Up @@ -4238,7 +4237,6 @@ service:
rows:
- - 1
rowsAffected: 0
lastInsertRowid: lastInsertRowid
source:
openapi: ../openapi.yml
display-name: sqlite
Expand Down Expand Up @@ -4272,7 +4270,7 @@ docs: SQLite
"links": {
"self": "self",
},
"profileImageUrl": "profileImageUrl",
"profileImageUrl": null,
"url": "https://val.town/u/tmcw",
"username": "tmcw",
},
Expand Down Expand Up @@ -4441,7 +4439,7 @@ service:
id: 00000000-0000-0000-0000-000000000000
bio: Hello world
username: tmcw
profileImageUrl: profileImageUrl
profileImageUrl: null
url: https://val.town/u/tmcw
links:
self: self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,12 @@ export class ExampleConverter extends AbstractConverter<AbstractConverterContext
};
} else {
const propExampleFromParent = exampleObj[key];
const propertyExample = propExampleFromParent ?? this.maybeResolveSchemaExample(property);
// Use the example from parent if it exists (including explicit null values)
// Only fall back to schema example if the property is truly undefined
const propertyExample =
propExampleFromParent !== undefined
? propExampleFromParent
: this.maybeResolveSchemaExample(property);
const exampleConverter = new ExampleConverter({
breadcrumbs: [...this.breadcrumbs, key],
context: this.context,
Expand Down
Loading