Conversation
- OpenApiInfo - OpenApiContact - OpenApiLicense - OpenApiExternalDocs - OpenApiSecurityRequirements - OpenApiTag
| Style = ParameterStyle.Form, | ||
| Explode = false, | ||
| AllowReserved = false | ||
| }, |
There was a problem hiding this comment.
This doesn't look right. Copy-paste error? #Closed
There was a problem hiding this comment.
There was a problem hiding this comment.
| comparisonContext | ||
| .GetComparer<TReference>() | ||
| .Compare(source, target, comparisonContext); | ||
| } |
There was a problem hiding this comment.
This seems like something that should be in its own class OpenApiReferenceComparer rather than the base class #Closed
There was a problem hiding this comment.
I tried that but didn't implement it b/c even if i add as separate comparer class like below
public class OpenApiReferenceComparer : OpenApiComparerBase where T : IOpenApiReferenceable
It can't be registered under OpenApiComparerFactory, b/c the type of reference is an enum and can't register various reference comparer based on the value of enum,
That said i will still add the comparer class and reference it directly in the comparers where we diff reference.
In reply to: 223511051 [](ancestors = 223511051)
| newKeyInTarget, | ||
| target[newKeyInTarget]), | ||
| OpenApiComparedElementType = typeof(KeyValuePair<string, string>) | ||
| }); |
There was a problem hiding this comment.
Based on this http://jsonpatch.com/, this should be
WalkAndAddOpenApiDifference(
comparisonContext,
newKeyInTarget,
new OpenApiDifference
{
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Add,
TargetValue = target[newKeyInTarget],
OpenApiComparedElementType = typeof(string)
}); #Closed
There was a problem hiding this comment.
I do not see a dictionary example for json patch , so i am not sure if this is correct, can you point me to a dictionary example that you might have found?
In reply to: 223511856 [](ancestors = 223511856)
There was a problem hiding this comment.
C# Dictionary should be treated as a JSON object.
The first example on http://jsonpatch.com/
See the second line:
{ "op": "add", "path": "/hello", "value": ["world"] }
and the third line:
{ "op": "remove", "path": "/foo" }
In reply to: 223857178 [](ancestors = 223857178,223511856)
| removedKeyFromSource, | ||
| source[removedKeyFromSource]), | ||
| OpenApiComparedElementType = typeof(KeyValuePair<string, string>) | ||
| }); |
There was a problem hiding this comment.
WalkAndAddOpenApiDifference(
comparisonContext,
removedKeyFromSource,
new OpenApiDifference
{
OpenApiDifferenceOperation = OpenApiDifferenceOperation.Remove,
SourceValue = source[removedKeyFromSource],
OpenApiComparedElementType = typeof(string)
}); #Closed
|
|
||
| comparisonContext | ||
| .GetComparer<TReference>() | ||
| .Compare(source, target, comparisonContext); |
There was a problem hiding this comment.
What's the example case of this? If the references are indeed pointing to the same object, wouldn't these two objects always be the same? #Closed
There was a problem hiding this comment.
if Id are same we can't assume that the referenced object will be same too.
In reply to: 223515635 [](ancestors = 223515635)
There was a problem hiding this comment.
That could be true in the C# sense, but from the way we use the Reference object, how would that be possible? If the ID is the same, doesn't that mean this refers to exactly the same object. In fact, the reference object will only be serialized as $ref (or plain string in case of tag) with id only.
In reply to: 223858079 [](ancestors = 223858079,223515635)
There was a problem hiding this comment.
Chatted with Shweta. We will do a deep comparison here, so that it's useful for API consumer to see what exactly has changed to an API. Same principle applies to the Security Scheme in Security Requirement.
In reply to: 223899238 [](ancestors = 223899238,223858079,223515635)
| OpenApiDifferenceOperation = OpenApiDifferenceOperation.Add, | ||
| TargetValue = new KeyValuePair<OpenApiSecurityScheme, IList<string>>( | ||
| newSecuritySchemeInTarget, | ||
| targetSecurityRequirement[newSecuritySchemeInTarget]), |
There was a problem hiding this comment.
This should not be a key-value pair. We are already pointing the the value itself - just use the IList. #Closed
| { | ||
| WalkAndAddOpenApiDifference( | ||
| comparisonContext, | ||
| newSecuritySchemeInTarget.Reference.Id, |
There was a problem hiding this comment.
newSecuritySchemeInTarget.Reference.Id, [](start = 19, length = 40)
Does this yield the right string (i.e. just the security scheme name, not the entire json pointer)? #Closed
There was a problem hiding this comment.
| OpenApiDifferenceOperation = OpenApiDifferenceOperation.Remove, | ||
| SourceValue = new KeyValuePair<OpenApiSecurityScheme, IList<string>>( | ||
| sourceSecurityScheme, | ||
| sourceSecurityRequirement[sourceSecurityScheme]), |
There was a problem hiding this comment.
similar to above. This should not be a Key Value Pair #Closed
| sourceSecurityScheme.Reference.Id, | ||
| () => comparisonContext | ||
| .GetComparer<OpenApiSecurityScheme>() | ||
| .Compare(sourceSecurityScheme, targetSecurityScheme, comparisonContext)); |
There was a problem hiding this comment.
I don't think we should be comparing the OpenApiSecurityScheme. Shouldn't we be comparing the list of strings in the value side? #Closed
There was a problem hiding this comment.
why not compare Security scheme? if source and target reference two different types of security schemes there should be a diff for it.
In reply to: 223516846 [](ancestors = 223516846)
There was a problem hiding this comment.
That said i was thinking whether to compare scope list or not, and if i do compare how the pointer should be ?
e.g. if source is
new OpenApiSecurityRequirement
{
[
new OpenApiSecurityScheme
{
Reference = new OpenApiReference {Type = ReferenceType.SecurityScheme, Id = "scheme1"}
}
] = new List
{
"scope1",
"scope2",
"scope3"
}
}
and Target is
new OpenApiSecurityRequirement
{
[
new OpenApiSecurityScheme
{
Reference = new OpenApiReference {Type = ReferenceType.SecurityScheme, Id = "scheme1"}
}
] = new List
{
"scope2",
"scope3"
}
}
Then should diff be #/0 --> remove?
In reply to: 223852204 [](ancestors = 223852204,223516846)
There was a problem hiding this comment.
-
We should not compare SecurityScheme here because we only use its name as a key. From the OpenAPI document standpoint, only the key (id of the ref) will show up. Even if we manually craft the DOM to actually be different (say, add some random other things into the Security Scheme), the resulting serialized document will be exactly the same for this SecurityRequirement object.
-
Ideally, diff in the above case should be Remove /scheme1/0. However, from the way you handle the Ordered List (in OpenApiOrderedListComparer), this can be
- Update /scheme1/0 from scope1 to scope2
- Update /scheme1/1 from scope2 to scope3
- Remove /scheme1/2
which is also okay (and correct).
In reply to: 223852979 [](ancestors = 223852979,223852204,223516846)
There was a problem hiding this comment.
If we want to be really fancy, we can use an algo for "minimum edit distance" to find the best list of update/add/remove (think about one scope being one letter in the original problem). I'd strongly suggest we don't do it in this PR though :)
In reply to: 223900360 [](ancestors = 223900360,223852979,223852204,223516846)
There was a problem hiding this comment.
I will have a separate PR to compare scopes
In reply to: 224182344 [](ancestors = 224182344,223900360,223852979,223852204,223516846)
| ] = new List<string> | ||
| { | ||
| "scope4", | ||
| "scope5" |
There was a problem hiding this comment.
Try add test cases with two different scope lists #Closed
There was a problem hiding this comment.
I am currently not comparing scope lists, have replied on other thread on question i have on diff of it
In reply to: 223517115 [](ancestors = 223517115)
There was a problem hiding this comment.
|
This file should be comparing Info objects, not Encoding objects.
#Closed
|
Added comparison logic for