Modify, clean, refactor for the OpenApiDocument and OpenApiPaths#46
Conversation
| writer.WriteObject("info", Info, (w, i) => i.WriteAsV3(w)); | ||
| writer.WriteList("servers", Servers, (w, s) => s.WriteAsV3(w)); | ||
| writer.WritePropertyName("paths"); | ||
| // openapi |
There was a problem hiding this comment.
// openapi [](start = 12, length = 10)
These comments look cluttered to me. I don't think they are necessary. What do you think?
There was a problem hiding this comment.
I suggest to leave these comments there for better understanding which parts are being written.
Is it ok for you?
| writer.WriteList("servers", Servers, (w, s) => s.WriteAsV3(w)); | ||
| writer.WritePropertyName("paths"); | ||
| // openapi | ||
| writer.WriteStringProperty(OpenApiConstants.OpenApiDocOpenApi, "3.0.0"); |
There was a problem hiding this comment.
"3.0.0" [](start = 75, length = 7)
Leverage your constant
There was a problem hiding this comment.
Or use the Version property in this class
| /// <summary> | ||
| /// REQUIRED.This string MUST be the semantic version number of the OpenAPI Specification version that the OpenAPI document uses. | ||
| /// </summary> | ||
| public Version Version { get; set; } = OpenApiConstants.OpenApiDocDefaultVersion; |
There was a problem hiding this comment.
Does this need to exist here? It's not in the spec. #Closed
There was a problem hiding this comment.
Oh. I see what's being done here. This corresponds to the "openapi" property in the spec. Can we name this SpecificationVersion to avoid confusion with the other version in the Info?
| writer.WriteStringProperty(OpenApiConstants.OpenApiDocSwagger, "2.0"); | ||
|
|
||
| // info | ||
| writer.WriteObject("info", Info, (w, i) => i.WriteAsV2(w)); |
There was a problem hiding this comment.
"info" [](start = 31, length = 6)
leverage your constant
| { | ||
| internal static class OpenApiDocumentTestHelper | ||
| { | ||
| public static void CreatePath(this OpenApiDocument doc, string key, Action<OpenApiPathItem> configure) |
There was a problem hiding this comment.
public [](start = 8, length = 6)
Document. Also, where is this used?
There was a problem hiding this comment.
It seems only used in the ExampleTests.cs and ValidationTests.cs. So, I move it from OpenApiDocument to test project.
There was a problem hiding this comment.
changed "doc" to "document"
| writer.WriteExtensions(Extensions); | ||
|
|
||
| writer.WriteEndObject(); | ||
| } |
There was a problem hiding this comment.
I'd rather have WriteAsV2 and WriteAsV3 implement this logic separately. It might be duplicate code, but technically they are somewhat independent, and it will be easier to fix them individually if needs be in the future.
What do you think?
There was a problem hiding this comment.
Either is ok for me. But I changed follow up your suggestion.
|
Let's add more extensive unit tests for paths. |
|
I want to leave it when I back to change "OpenApiPathItem".
done. |
| writer.WriteObject("info", Info, (w, i) => i.WriteAsV2(w)); | ||
| SerializeHostInfo(writer, Servers); | ||
| // swagger | ||
| writer.WriteStringProperty(OpenApiConstants.OpenApiDocSwagger, OpenApiConstants.OpenApiDocSwaggerVersion); |
There was a problem hiding this comment.
OpenApiConstants.OpenApiDocSwaggerVersion [](start = 75, length = 41)
If above uses SpecVersion, we should use SpecVersion here too.
|
@xuzhg I can take up the V2 object writing issues. I'll sign off. |
|
Great, Thanks. |
docs: adds the v3 upgrade guide
Modify, cleanup, refactor, correct for OpenApiDocument
Create a new class named OpenApiDictionaryElement
Modify, cleanup, refactor, correct for OpenApiPaths