-
Notifications
You must be signed in to change notification settings - Fork 285
Validation for custom extensions #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
7b42b1b
4ffe083
2789c0b
fed72e4
909a0d7
7ca70f2
60a26b2
41b049d
048518a
a42e62a
7e1f151
e9d2569
3fd21d2
824e3e2
acd1a45
d4597fc
c19a883
6d7eca5
85ba08c
0d68e70
9dba5fd
2e7c33a
474944d
576de46
8d44882
de7e355
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| // See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
| // for the documentation about the tasks.json format | ||
| "version": "2.0.0", | ||
| "tasks": [ | ||
| { | ||
| "label": "build", | ||
| "type": "shell", | ||
| "command": "msbuild", | ||
| "args": [ | ||
| "/property:GenerateFullPaths=true", | ||
| "/t:build" | ||
| ], | ||
| "group": "build", | ||
| "presentation": { | ||
| "reveal": "silent" | ||
| }, | ||
| "problemMatcher": "$msCompile" | ||
| }, | ||
| { | ||
| "label": "workbench", | ||
| "type": "shell", | ||
| "command": "src/Microsoft.OpenApi.WorkBench/bin/Debug/Microsoft.OpenApi.WorkBench.exe", | ||
| "problemMatcher": [] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| using Microsoft.OpenApi.Any; | ||
| using Microsoft.OpenApi.Interfaces; | ||
| using Microsoft.OpenApi.Readers.ParseNodes; | ||
| using Microsoft.OpenApi.Validations; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Microsoft.OpenApi.Readers | ||
| { | ||
| /// <summary> | ||
| /// Configuration settings to control how OpenAPI documents are parsed | ||
| /// </summary> | ||
| public class OpenApiReaderSettings | ||
| { | ||
| /// <summary> | ||
| /// Dictionary of parsers for converting extensions into strongly typed classes | ||
| /// </summary> | ||
| public Dictionary<string, Func<IOpenApiAny , IOpenApiExtension>> ExtensionParsers { get; set; } = new Dictionary<string, Func<IOpenApiAny, IOpenApiExtension>>(); | ||
|
|
||
| /// <summary> | ||
| /// Rules to use for validating OpenAPI specification. If none are provided a default set of rules are applied. | ||
| /// </summary> | ||
| public ValidationRuleSet RuleSet { get; set; } | ||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. | ||
|
|
||
| using Microsoft.OpenApi.Writers; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace Microsoft.OpenApi.Any | ||
|
|
@@ -14,5 +15,22 @@ public class OpenApiArray : List<IOpenApiAny>, IOpenApiAny | |
| /// The type of <see cref="IOpenApiAny"/> | ||
| /// </summary> | ||
| public AnyType AnyType { get; } = AnyType.Array; | ||
|
|
||
| /// <summary> | ||
| /// Write out contents of OpenApiArray to passed writer | ||
| /// </summary> | ||
| /// <param name="writer">Instance of JSON or YAML writer.</param> | ||
| public void Write(IOpenApiWriter writer) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. public? not internal? #WontFix
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it needs to be public because it is part of an interface that will be implemented by any custom extension implementation. In reply to: 161353844 [](ancestors = 161353844) |
||
| { | ||
| writer.WriteStartArray(); | ||
|
|
||
| foreach (var item in this) | ||
| { | ||
| writer.WriteAny(item); | ||
| } | ||
|
|
||
| writer.WriteEndArray(); | ||
|
|
||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to separate two constructors? #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. The optional parameter conveys that settings are optional and having one constructor prevents someone from adding code to one ctor that needs to be called from both.
In reply to: 161353699 [](ancestors = 161353699)