-
Notifications
You must be signed in to change notification settings - Fork 279
A variety of bug fixes for 1.1 preview #267
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
Conversation
Added parsing externalValue to Examples Object
Update to v1.0.1
| /// <summary> | ||
| /// REQUIRED. The available paths and operations for the API. | ||
| /// </summary> | ||
| public OpenApiPaths Paths { get; set; } = new OpenApiPaths(); |
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.
= new OpenApiPaths(); [](start = 47, length = 22)
The reason we had this was because OpenApiPaths is a collection (a dictionary). Is it causing issue? #Resolved
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.
Yes. We don't raise provide a validation error when a user provides a document that doesn't have a paths property. We used to validate this in the reader, but we since moved it into our Validator. #Closed
| /// <summary> | ||
| /// URL where relative references should be resolved from if the description does not contain Server definitions | ||
| /// </summary> | ||
| public Uri BaseUrl { get; set; } = new Uri("https://example.org/"); |
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.
Uri("https://example.org/"); [](start = 46, length = 29)
The spec says this:
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#fixed-fields
An array of Server Objects, which provide connectivity information to a target server. If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of /. #Closed
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.
Actually, that might be unrelated. Let me read through more, and I'll readdress this.
In reply to: 193214821 [](ancestors = 193214821)
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.
OK. I finished looking through the whole PR. I don't think we should use an arbitrary URL here.
I'd handle this inside the deserializer itself (see my other comment there about special cases). It seems a bit confusing to have a baseUrl in the reader/parsingContext, especially the one that's not given by the caller.
In reply to: 193215807 [](ancestors = 193215807,193214821)
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 can leave this null by default and fix the MakeServer stuff, but we still need a way for the user to specify the URL where the doc came from. #Closed
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.
| { | ||
| var server = new OpenApiServer(); | ||
| server.Url = scheme + "://" + (host ?? "example.org/") + (basePath ?? "/"); | ||
| var ub = new UriBuilder(scheme, host) |
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.
ub [](start = 24, length = 2)
nit, uriBuilder #Closed
| } | ||
|
|
||
| // Fill in missing information based on the defaultUrl | ||
| host = host ?? defaultUrl.GetComponents(UriComponents.NormalizedHost, UriFormat.SafeUnescaped); |
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.
defaultUrl.GetComponents(UriComponents.NormalizedHost, UriFormat.SafeUnescaped); [](start = 27, length = 80)
V2 spec:
If the host is not included, the host serving the documentation is to be used (including the port).
This is in line with V3 spec:
If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of /.
Server.url "supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served."
There are 8 cases in total:
=> Case 1 & 2: Host empty + schemes not empty (regardless of basePath) => This is weird. I don't know how to represent this in V3. Maybe we can simply ignore the schemes since we don't really have a way to handle it.
=> Case 3: Host empty + schemes empty + basePath not empty => Essentially, what this means is we use the Host serving the doc but with appended path. To represent this in V3, we simply need the basePath in Server.url
=> Case 4: Host empty + schemes empty + basePath empty => You handled this. This means no need for Server object in V3.
=> Case 5 & 6: Host not empty + schemes empty (regardless of basePath) => We can just use the host and basePath without schemes in Server.url in V3? That still seems like a valid URL to me.
=> Case 7 & 8: Host not empty + schemes not empty (regardless of basePath) => This is the normal case. Server.url will simply be schemes + host + basePath. #Resolved
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.
Just so we are the same page, the BaseUrl in the Settings is where you put "the Host serving the doc". I think what you are saying, is you don't want an arbitrary default for "host serving the doc" when one isn't provided. Is that correct?
#Closed
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.
ah okay. Correct - it's a little odd to default to an arbitrary example.org. Also, the conversion is possible (except case 1&2) above even without the info on "host serving the doc", so I'm not sure if we really need it.
In reply to: 193228718 [](ancestors = 193228718)
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.
Ah. I see that the baseUrl has to be there for reference resolving. In that case, I think we should leave it blank like you suggested, handle the MakeServers here, and use the property for Reference Resolving as planned.
In reply to: 193231179 [](ancestors = 193231179,193228718)
|
|
||
| foreach (var response in operation.Responses.Values) | ||
| { | ||
| ProcessProduces(response, node.Context); |
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.
ProcessProduces(response, node.Context); [](start = 12, length = 44)
Isn't this handled in OpenApiResponseDeserializer.cs line 123? #Closed
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 had to put it in operation for the case when produces came after responses. But I needed it also in responses for when responses are defined at the root level as a reusable thing. So I made it work when you call it in both places. #Closed
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.
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.
🕐
| throw new OpenApiException(string.Format(SRResource.OpenApiSpecVersionNotSupported, writer.Settings.SpecVersion)); | ||
| } | ||
|
|
||
| writer.Flush(); |
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.
Can we leverage the method above?
return element.Serialize(writer, writer.Settings.SpecVersion); #Resolved
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.
| { | ||
| var server = new OpenApiServer(); | ||
| server.Url = scheme + "://" + (host ?? "example.org/") + (basePath ?? "/"); | ||
| var uriBuilder = new UriBuilder(scheme, host) |
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.
Check that scheme is not null or empty #Resolved
| { | ||
| if (!String.IsNullOrEmpty(host)) | ||
| { | ||
| host = "//" + host; |
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.
= "//" + host; [](start = 25, length = 14)
nit, it wasn't obvious to me in the beginning that we need this "//" to denote "the current protocol".
Could you add some comments to explain this? #Resolved
| var uriBuilder = new UriBuilder() | ||
| { | ||
| Scheme = null, | ||
| Host = host, |
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.
The way this works is kinda strange - I'd hope the UriBuilder can add that "//" for us when the Scheme is null. However, it seems like the default behavior is that it would add http instead - which is not what we want. #Resolved
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.
Yeah, I was hoping UriBuilder would add the // but sadly it doesn't. Maybe we could consider building our own UriBuilder to clean this up. But Uris are tricky beasts, so I didn't want to open that can of worms just now.
In reply to: 193594097 [](ancestors = 193594097)
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.
![]()
Uh oh!
There was an error while loading. Please reload this page.