Add a prototype extension methods to covert string to OpenApiAny object#27
Add a prototype extension methods to covert string to OpenApiAny object#27xuzhg wants to merge 1 commit intomicrosoft:masterfrom xuzhg:ExtensionMethodsForIOpenApiAny
Conversation
|
@xuzhg, |
| namespace Microsoft.OpenApi | ||
| { | ||
| /// <summary> | ||
| /// Extension methods covert <see cref="System.String"/> to <see cref="IOpenApiAny"/> |
There was a problem hiding this comment.
covert [](start = 26, length = 6)
to convert
|
|
||
|
|
||
| // If we can't distiguish the type, just return it as string. | ||
| return new OpenApiString(input); |
There was a problem hiding this comment.
OpenApiString [](start = 23, length = 13)
Per our discussion in #25, are you planning to create OpenApiGenericExtension separately?
There was a problem hiding this comment.
I want to OpenApiAnyExtensions.cs to be severed as OpenApiGenericExtension.
And I don't think OpenApiGenericExtension should be implemented the interface IOpenApiAny.
We don't have an any type as "Generic", Right?
There was a problem hiding this comment.
Could you explain why this is the case? "And I don't think OpenApiGenericExtension should be implemented the interface IOpenApiAny."
There was a problem hiding this comment.
I don't actually think we need the IOpenApiAny interface. There are two places that use Any in the spec. Examples and Extensions and both of those should be handled specifically. The behavior of the two things are different, so trying toi handle then as a generic Any is not going to be ideal.
There was a problem hiding this comment.
@darrelmiller Would you please take a look the PR: #31, then let's figure out why I think we need the IOpenApiAny interface.
| /// <summary> | ||
| /// Extension methods covert <see cref="System.String"/> to <see cref="IOpenApiAny"/> | ||
| /// </summary> | ||
| internal static class OpenApiAnyExtensions |
There was a problem hiding this comment.
OpenApiAnyExtensions [](start = 26, length = 20)
This name is a little weird. Usually in C#, XXXExtensions contains extensions for XXX class.
What do you think about this?
-
Create OpenApiAnyGeneric : IOpenApiAny
-
That class contains the method public IOpenApiAny ConvertToSpecificOpenApiAny (logic is what you have here, but with the last return statement returning OpenApiAnyGeneric)
-
The way this method is called is that you first initialize OpenApiAnyGeneric(string input) and then call .ConvertToSpecificOpenApiAny
|
Convert string to the correct IOpenApiAny (or a generic IOpenApiAny) should be a functionality in the Reader project. Right? |
|
@xuzhg Good point... That sounds right to me. In that case, the extension OpenApiAnyGeneric.ConvertToSpecificOpenApiAny I mentioned above can go into the Reader. |
|
@PerthCharern I created an issue: #43 By the way, I only saw the Yaml reader, do we have the Json Reader? Or do I misunderstand something? |
|
@xuzhg This is my current understanding. If you look at FixtureTests, you can see that the YamlStream can actually load json string, so we don't need two separate readers. I haven't deeply looked into this, but the unit tests seem to be passing, so that's my impression. The folder YamlReader probably should be renamed to OpenApiReader. |
|
totally agree that the "YamlReader" folder confused a lot. Also, YamlStream both for "Json" and "Yaml" format. |
|
In #54, I think that's the place where the Please take a look. Thanks. |
|
I think we answer the question related to |
…a718-452893b94d3f feat: Add deprecated field to SecurityScheme for OpenAPI 3.2.0
Add a prototype extension methods to covert string to IOpenApiAny object.