Skip to content

Commit da35136

Browse files
committed
make some fixes from suggestions in Slack
1 parent 8491818 commit da35136

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

_docs/schema/examples/custom-vocabs.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class MaxDateKeyword : IJsonSchemaKeyword
4242

4343
// Implements IJsonSchemaKeyword
4444
public KeywordConstraint GetConstraint(SchemaConstraint schemaConstraint,
45-
IReadOnlyList<KeywordConstraint> localConstraints,
45+
ReadOnlySpan<KeywordConstraint> localConstraints,
4646
EvaluationContext context)
4747
{
4848
throw new NotImplementedException();
@@ -165,9 +165,9 @@ Then they need to be registered. This is done on the schema validation options.
165165
options.SchemaRegistry.Register(new Uri("http://mydates.com/vocab/schema"), DatesMetaSchema);
166166
options.SchemaRegistry.Register(new Uri("http://mydates.com/dialect/schema"), DatesDialectMetaSchema);
167167

168-
// Register the vocabulary. This automatically registers the keywords
169-
// defined by the vocabulary.
170-
options.VocabularyRegistry.Register(DatesVocabulary);
168+
// Register the vocabulary.
169+
// You'll still need to register the keywords as shown in the previous section.
170+
VocabularyRegistry.Register(DatesVocabulary);
171171
```
172172

173173
And that's it. The vocabulary and keyword are ready for use.

_docs/schema/schemagen/examples/attribute.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ permalink: /schema/examples/:title/
66
icon: fas fa-tag
77
order: "01.5.4.3"
88
---
9-
In the [previous example](schema-gen-intent.md) we created a keyword intent to represent a new `maxDate` keyword during generation.
9+
In the [previous example](schema-gen-intent.md) we created a keyword intent to represent the [`maxDate` keyword](/schema/examples/custom-vocabs/#example-schema-vocabs-keyword) during generation.
1010

1111
Now we need a way to add it into the generation. This keyword is a validation constraint that you might expect to see as an attribute, so we'll do that.
1212

@@ -26,7 +26,7 @@ public class MaxDateAttribute : Attribute, IAttributeHandler
2626
}
2727

2828
// It's not necessary to implement this explicitly, but I like to.
29-
void IAttributeHandler.AddConstraints(SchemaGeneratorContext context)
29+
void IAttributeHandler.AddConstraints(SchemaGeneratorContextBase context)
3030
{
3131
var attribute = context.Attributes.OfType<MaxDateAttribute>()
3232
.FirstOrDefault();

_docs/schema/schemagen/examples/generator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TimeSpanSchemaGenerator : ISchemaGenerator
2121
return type == typeof(TimeSpan);
2222
}
2323

24-
public void AddConstraints(SchemaGeneratorContext context)
24+
public void AddConstraints(SchemaGeneratorContextBase context)
2525
{
2626
context.Intents.Add(new TypeIntent(SchemaValueType.String));
2727
context.Intents.Add(new FormatIntent(Formats.Duration));

_docs/schema/schemagen/examples/intent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ order: "01.5.4.2"
88
---
99
This example shows how to extend schema generation to output a new keyword.
1010

11-
Suppose we've implemented the `maxDate` keyword (see the "Custom Vocabularies" example). Now we need a way to generate schemas that contain it.
11+
Suppose we've implemented the `maxDate` keyword from the [Custom Vocabularies example](/schema/examples/custom-vocabs/#example-schema-vocabs-keyword). Now we need a way to generate schemas that contain it.
1212

1313
For this we need to create a _keyword intent_.
1414

_docs/schema/schemagen/examples/refiner.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ It first looks at the generated schema to determine whether it can add a `null`
1919
```c#
2020
internal class NullabilityRefiner : ISchemaRefiner
2121
{
22-
public bool ShouldRun(SchemaGeneratorContext context)
22+
public bool ShouldRun(SchemaGeneratorContextBase context)
2323
{
2424
// we only want to run this if the generated schema has a `type` keyword
2525
return context.Intents.OfType<TypeIntent>().Any();
2626
}
2727

28-
public void Run(SchemaGeneratorContext context)
28+
public void Run(SchemaGeneratorContextBase context)
2929
{
3030
// find the type keyword
3131
var typeIntent = context.Intents.OfType<TypeIntent>().Firs();

_docs/schema/schemagen/schema-generation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ permalink: /schema/schemagen/:title/
66
icon: fas fa-tag
77
order: "01.5.1"
88
---
9-
*JsonSchema.Net.Generation* is an extension package to *JsonSchema.Net* that provides JSON Schema generation from .Net types.
9+
_JsonSchema.Net.Generation_ is an extension package to _JsonSchema.Net_ that provides JSON Schema generation from .Net types.
1010

1111
Using it is quite simple. First you need a `JsonSchemaBuilder`. Then...
1212

@@ -368,7 +368,7 @@ public class MaximumAttribute : Attribute, IAttributeHandler<MaximumAttribute>
368368
Value = value;
369369
}
370370
371-
void IAttributeHandler.AddConstraints(SchemaGeneratorContext context)
371+
void IAttributeHandler.AddConstraints(SchemaGeneratorContextBase context)
372372
{
373373
if (!context.Type.IsNumber()) return;
374374

0 commit comments

Comments
 (0)