Skip to content

Commit 3816543

Browse files
committed
make deprecated types used in docs wrapped in optional
1 parent 0817e2f commit 3816543

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ struct Person {
367367
std::vector<Person>>
368368
children;
369369
float salary;
370-
rfl::Deprecated<"Use Salary Instead", "Wage in dollars", int> wage;
370+
rfl::Deprecated<"Use Salary Instead", "Wage in dollars", std::optional<int>> wage;
371371
};
372372

373373
const std::string json_schema = rfl::json::to_schema<Person>();
@@ -376,7 +376,7 @@ const std::string json_schema = rfl::json::to_schema<Person>();
376376
The resulting JSON schema looks like this:
377377
378378
```json
379-
{"$schema":"https://json-schema.org/draft/2020-12/schema","$ref":"#/$defs/Person","$defs":{"Person":{"type":"object","properties":{"children":{"type":"array","description":"The person's children. Pass an empty array for no children.","items":{"$ref":"#/$defs/Person"}},"email":{"type":"string","description":"Must be a proper email in the form xxx@xxx.xxx.","pattern":"^[a-zA-Z0-9._%+\\-]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,}$"},"first_name":{"type":"string"},"last_name":{"type":"string"},"salary":{"type":"number"}},"required":["children","email","first_name","last_name","salary"]}}}
379+
{"$schema":"https://json-schema.org/draft/2020-12/schema","$ref":"#/$defs/Person","$defs":{"Person":{"type":"object","properties":{"children":{"type":"array","description":"The person's children. Pass an empty array for no children.","items":{"$ref":"#/$defs/Person"}},"email":{"type":"string","description":"Must be a proper email in the form xxx@xxx.xxx.","pattern":"^[a-zA-Z0-9._%+\\-]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,}$"},"first_name":{"type":"string"},"last_name":{"type":"string"},"salary":{"type":"number"},"wage":{"type":"integer","description":"Wage in dollars","deprecated":true,"deprecationMessage":"Use Salary Instead"}},"required":["children","email","first_name","last_name","salary"]}}}
380380
```
381381

382382
Note that this is currently supported for JSON only, since most other formats do not support schemata in the first place.

docs/json_schema.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ You can mark fields as deprecated in the JSON schema using `rfl::Deprecated`. Th
202202
```cpp
203203
struct Person {
204204
rfl::Deprecated<"Use 'full_name' instead.", "The person's first name", std::optional<std::string>>
205-
first_name;
205+
std::optional<first_name>;
206206
rfl::Description<"The person's full name", std::string> full_name;
207207
float salary;
208208
};
@@ -235,7 +235,6 @@ const std::string json_schema = rfl::json::to_schema<Person>(rfl::json::pretty);
235235
}
236236
},
237237
"required": [
238-
"first_name",
239238
"full_name",
240239
"salary"
241240
]

0 commit comments

Comments
 (0)