Skip to content

Commit 212b128

Browse files
committed
fix some typos; add extension method tip
1 parent 71ae0d1 commit 212b128

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.jekyll-metadata

2.05 KB
Binary file not shown.

_docs/schema/schemagen/schema-generation.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,36 @@ The generator will handle most common types:
140140

141141
For POCOs, read-only properties and fields will be marked with a `readOnly` keyword, and write-only properties (those with only a setter) will be marked with a `writeOnly` keyword. These behaviors can be overridden by applying the appropriate keyword with a `false` value.
142142

143-
Lastly, property names will either be listed as declared in code (default) or sorted by name. This is controlled via the `SchemaGenerationConfiguration.PropertyOrder` property.
143+
Lastly, property names will either be listed as declared in code (default) or sorted by name. This is controlled via the `SchemaGeneratorConfiguration.PropertyOrder` property.
144144

145145
### XML comment support
146146

147147
In addition to the explicit attributes above, the XML comment `<Summary>` element can be configured to render to a `description` keyword. Because .Net saves this information into an external XML file instead of into the reflection data, you'll need to have a configuration object and register the XML filename.
148148

149149
```c#
150-
var config = new SchemaGenerationConfiguration();
150+
var config = new SchemaGeneratorConfiguration();
151151
// MyModel is any type from the assembly. A single registration will
152152
// cover the entire assembly.
153-
config.RegisterXmlCommentsFile<MyModel>("MyAssembly.xml");
153+
config.RegisterXmlCommentFile<MyModel>("MyAssembly.xml");
154154

155155
var schema = new JsonSchemaBuilder.FromType<MyModel>(config).Build();
156156
```
157157

158158
> Explicitly using the `[Description]` attribute will override XML comments, and XML comments on members will override XML comments on types.
159159
{: .prompt-info }
160160

161+
> It has been noted by a user that this extension method can be useful if the XML comments file is adjacent to the assembly in the file system.
162+
>
163+
> ```c#
164+
> public static void RegisterXmlCommentFile<T>(this SchemaGeneratorConfiguration configuration)
165+
> {
166+
> configuration.RegisterXmlCommentFile<T>(typeof(T).Assembly.Location.Replace(".dll", ".xml"))
167+
> }
168+
> ```
169+
>
170+
> This will likely be added in a future version.
171+
{: .prompt-tip }
172+
161173
### Nullability {#schema-schemagen-nullability}
162174
163175
There is a discrepancy between how .Net does validation and how JSON Schema does validation that centers primarily around nullable types and the `[Required]` attribute.

0 commit comments

Comments
 (0)