Make Open API Any reader works in the reader project#54
Make Open API Any reader works in the reader project#54xuzhg merged 3 commits intomicrosoft:masterfrom xuzhg:ReadAny
Conversation
|
@xuzhg, |
| @@ -0,0 +1,58 @@ | |||
| // ------------------------------------------------------------ | |||
| // Copyright (c) Microsoft Corporation. All rights reserved. | |||
There was a problem hiding this comment.
This C# file will be moved into "Models" folder later.
Because I have other PR which has the same file, in order to avoid conflict in the later merge, I add it in the root folder temporary.
| public static PatternFieldMap<OpenApiInfo> InfoPatternFields = new PatternFieldMap<OpenApiInfo> | ||
| { | ||
| { (s)=> s.StartsWith("x-"), (o,k,n)=> o.Extensions.Add(k, new OpenApiString(n.GetScalarValue())) } | ||
| { (s)=> s.StartsWith("x-"), (o,k,n)=> o.AddExtension(k, n.CreateAny()) } |
There was a problem hiding this comment.
I didn't change others in this PR, but will be do later
| return new OpenApiBoolean(false); | ||
| } | ||
|
|
||
| // TODO: add more codes to identify each primitive types |
There was a problem hiding this comment.
do you know the suitable way to identify each primitive type?
There was a problem hiding this comment.
We can add this incrementally. I think we are on the right track.
| name: Darrel Miller | ||
| url: http://www.bizcoder.com | ||
| email: [email protected] | ||
| x-list: |
There was a problem hiding this comment.
It looks YamlReader can't process "object" embedded in the "list". Do you know it's by design or not?
There was a problem hiding this comment.
It's not by design. YAML spec supports this and YAML is technically a superset of JSON, so anything that works in JSON must be supported in YAML.
There was a problem hiding this comment.
Yes. I tested it. Yaml reader supports the following:
{
"a": "a1",
"b": [
"false",
{
"c": "c1"
}
]
}
"b" list has the "Boolean" and "Object" element
|
@PerthCharern @darrelmiller ping... |
| /// <param name="extension">The extensible Open API element. </param> | ||
| /// <param name="name">The extension name.</param> | ||
| /// <param name="any">The extension value.</param> | ||
| public static void AddExtension<T>(this T extension, string name, IOpenApiAny any) |
There was a problem hiding this comment.
extension [](start = 50, length = 9)
call this element
|
The change to .csproj file is missing |
|
|
||
| if (!name.StartsWith(OpenApiConstants.OpenApiDocExtensionFieldNamePrefix)) | ||
| { | ||
| throw new OpenApiException(SRResource.ExtensionFieldNameMustBeginWithXMinus); |
There was a problem hiding this comment.
ExtensionFieldNameMustBeginWithXMinus [](start = 54, length = 37)
I would call it either XDash or XHyphen.
| /// <returns></returns> | ||
| public virtual IOpenApiAny CreateAny() | ||
| { | ||
| throw new NotImplementedException(); |
There was a problem hiding this comment.
NotImplementedException [](start = 22, length = 23)
Technically NotSupportedException.
NotImplementedException is supposed to be for something temporary (i.e. sth you haven't implemented YET)
|
What do you mean? |
| { | ||
| string value = GetScalarValue(); | ||
|
|
||
| if (String.IsNullOrWhiteSpace(value)) |
There was a problem hiding this comment.
IsNullOrWhiteSpace [](start = 23, length = 18)
I think let's be conservative here, and only check null to get OpenApiNull.
White space might actually mean something...
| public static PatternFieldMap<OpenApiInfo> InfoPatternFields = new PatternFieldMap<OpenApiInfo> | ||
| { | ||
| { (s)=> s.StartsWith("x-"), (o,k,n)=> o.Extensions.Add(k, new OpenApiString(n.GetScalarValue())) } | ||
| { (s)=> s.StartsWith("x-"), (o,k,n)=> o.AddExtension(k, n.CreateAny()) } |
There was a problem hiding this comment.
k [](start = 43, length = 1)
wondering what k stands for. Maybe p for property is better?
There was a problem hiding this comment.
I will change it later
|
|
||
| /// <summary> | ||
| /// Looks up a localized string similar to The filed name of extension doesn't begin with x-.. | ||
| /// Looks up a localized string similar to The filed name '{0}' of extension doesn't begin with x-.. |
There was a problem hiding this comment.
'{0}' of extension doesn't [](start = 68, length = 42)
Does apostrophe cause issue in this file?
There was a problem hiding this comment.
It's auto generated file.
Make Open API Any
<IOpenApiAny>reader works in the reader project