Skip to content

Commit e2d02bd

Browse files
committed
chore: update README.md
1 parent 64dd7b2 commit e2d02bd

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

README.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@ Install-Package LarchSys.OpenAi.JsonSchema
2323
The following example demonstrates how to generate a JSON Schema using the **LarchSys.OpenAi.JsonSchema** library.
2424

2525
```csharp
26-
var options = new JsonSchemaOptions(SchemaDefaults.OpenAi);
26+
// use Json Options to control PropertyName and Enum serialization:
27+
var jsonOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web) {
28+
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
29+
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.SnakeCaseLower) }
30+
};
31+
32+
// use SchemaDefaults.OpenAi to enforce OpenAi roule set:
33+
var options = new JsonSchemaOptions(SchemaDefaults.OpenAi, jsonOptions);
2734

2835
var resolver = new DefaultSchemaGenerator();
29-
var schema = resolver.Generate<Document>(options);
36+
var schema = resolver.Generate(type, options);
3037

3138
var json = schema.ToJsonNode().ToJsonString(new JsonSerializerOptions() { WriteIndented = true });
3239
output.WriteLine(json);
@@ -55,45 +62,45 @@ public record Line(
5562
"type": "object",
5663
"description": "A document",
5764
"properties": {
58-
"Id": {
65+
"id": {
5966
"type": "integer",
6067
"description": "Id of the document"
6168
},
62-
"Name": {
69+
"name": {
6370
"type": "string",
6471
"description": "Document name"
6572
},
66-
"Lines": {
73+
"lines": {
6774
"type": "array",
6875
"description": "Text lines of the document",
6976
"items": {
7077
"type": "object",
7178
"description": "A line of text in a document",
7279
"properties": {
73-
"Number": {
80+
"number": {
7481
"type": "integer",
7582
"description": "Line number"
7683
},
77-
"Text": {
84+
"text": {
7885
"type": "string",
7986
"description": "Line text"
8087
}
8188
},
8289
"required": [
83-
"Number",
84-
"Text"
90+
"number",
91+
"text"
8592
],
8693
"additionalProperties": false
8794
}
8895
},
89-
"Next": {
96+
"next": {
9097
"description": "Next document in order",
9198
"anyOf": [
9299
{ "type": "null" },
93100
{ "$ref": "#" }
94101
]
95102
},
96-
"Prev": {
103+
"prev": {
97104
"description": "Prev document in order",
98105
"anyOf": [
99106
{ "type": "null" },
@@ -102,11 +109,11 @@ public record Line(
102109
}
103110
},
104111
"required": [
105-
"Id",
106-
"Name",
107-
"Lines",
108-
"Next",
109-
"Prev"
112+
"id",
113+
"name",
114+
"lines",
115+
"next",
116+
"prev"
110117
],
111118
"additionalProperties": false
112119
}
@@ -126,7 +133,7 @@ Contributions are welcome! Please fork this repository and submit a pull request
126133

127134
## License
128135

129-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
136+
This project is licensed under the MIT License. See the [LICENSE](LICENSE.txt) file for more information.
130137

131138
## Contact
132139

0 commit comments

Comments
 (0)