-
Notifications
You must be signed in to change notification settings - Fork 263
Fixes for issue 233 #236
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
Fixes for issue 233 #236
Changes from all commits
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Microsoft.OpenApi.Extensions; | ||
using Microsoft.OpenApi.Models; | ||
using Microsoft.OpenApi.Readers.ParseNodes; | ||
|
||
|
@@ -12,27 +13,45 @@ namespace Microsoft.OpenApi.Readers.V3 | |
/// </summary> | ||
internal static partial class OpenApiV3Deserializer | ||
{ | ||
private static readonly FixedFieldMap<OpenApiTag> _tagFixedFields = new FixedFieldMap<OpenApiTag> | ||
{ | ||
{ | ||
OpenApiConstants.Name, (o, n) => | ||
{ | ||
o.Name = n.GetScalarValue(); | ||
} | ||
}, | ||
{ | ||
OpenApiConstants.Description, (o, n) => | ||
{ | ||
o.Description = n.GetScalarValue(); | ||
} | ||
}, | ||
{ | ||
OpenApiConstants.ExternalDocs, (o, n) => | ||
{ | ||
o.ExternalDocs = LoadExternalDocs(n); | ||
} | ||
} | ||
}; | ||
|
||
private static readonly PatternFieldMap<OpenApiTag> _tagPatternFields = new PatternFieldMap<OpenApiTag> | ||
{ | ||
{s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, n.CreateAny())} | ||
}; | ||
|
||
public static OpenApiTag LoadTag(ParseNode n) | ||
{ | ||
var mapNode = n.CheckMapNode("tag"); | ||
|
||
var obj = new OpenApiTag(); | ||
var domainObject = new OpenApiTag(); | ||
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.
Why is this called domainObject? 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. So that when I cut and paste the code from one load to the next, I don't have to rename it :-) |
||
|
||
foreach (var node in mapNode) | ||
foreach (var propertyNode in mapNode) | ||
{ | ||
var key = node.Name; | ||
switch (key) | ||
{ | ||
case "description": | ||
obj.Description = node.Value.GetScalarValue(); | ||
break; | ||
case "name": | ||
obj.Name = node.Value.GetScalarValue(); | ||
break; | ||
} | ||
propertyNode.ParseField(domainObject, _tagFixedFields, _tagPatternFields); | ||
} | ||
|
||
return obj; | ||
return domainObject; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,8 +280,25 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) | |
|
||
// allowEmptyValue | ||
writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false); | ||
|
||
if (this.In == ParameterLocation.Query ) | ||
{ | ||
if (this.Style == ParameterStyle.Form && this.Explode == true) | ||
{ | ||
writer.WriteProperty("collectionFormat", "multi"); | ||
} | ||
else if (this.Style == ParameterStyle.PipeDelimited) | ||
{ | ||
writer.WriteProperty("collectionFormat", "pipes"); | ||
} | ||
else if (this.Style == ParameterStyle.PipeDelimited) | ||
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.
SpaceDelimited 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. Fixed. |
||
{ | ||
writer.WriteProperty("collectionFormat", "ssv"); | ||
} | ||
} | ||
} | ||
|
||
|
||
// extensions | ||
writer.WriteExtensions(Extensions); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,6 @@ public enum SecuritySchemeType | |
/// Use OAuth2 with OpenId Connect URL to discover OAuth2 configuration value. | ||
/// </summary> | ||
[Display("openIdConnect")] OpenIdConnect | ||
|
||
} | ||
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. nit remove empty line |
||
} |
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.
Cookie as well https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#style-values
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.
Cookie didn't exist in V2, so there is no need to try and translate csv for it,.
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.
Makes sense. Totally forgot :)