-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- adds support for logo, privacy, legal urls
Signed-off-by: Vincent Biret <[email protected]>
- Loading branch information
Showing
7 changed files
with
113 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 4 additions & 16 deletions
20
src/Kiota.Builder/OpenApiExtensions/OpenApiDescriptionForModelExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,20 @@ | ||
using System; | ||
using Microsoft.OpenApi; | ||
using Microsoft.OpenApi.Any; | ||
using Microsoft.OpenApi.Interfaces; | ||
using Microsoft.OpenApi.Writers; | ||
using Microsoft.OpenApi.Any; | ||
|
||
namespace Kiota.Builder.OpenApiExtensions; | ||
|
||
public class OpenApiDescriptionForModelExtension : IOpenApiExtension | ||
public class OpenApiDescriptionForModelExtension : OpenApiSimpleStringExtension | ||
{ | ||
public static string Name => "x-ai-description"; | ||
public string? Description | ||
{ | ||
get; set; | ||
} | ||
public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) | ||
{ | ||
ArgumentNullException.ThrowIfNull(writer); | ||
if (!string.IsNullOrWhiteSpace(Description)) | ||
{ | ||
writer.WriteValue(Description); | ||
} | ||
} | ||
protected override string? ValueSelector => Description; | ||
public static OpenApiDescriptionForModelExtension Parse(IOpenApiAny source) | ||
{ | ||
if (source is not OpenApiString rawString) throw new ArgumentOutOfRangeException(nameof(source)); | ||
return new OpenApiDescriptionForModelExtension | ||
{ | ||
Description = rawString.Value | ||
Description = ParseString(source) | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Kiota.Builder/OpenApiExtensions/OpenApiLegalInfoUrlExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.OpenApi.Any; | ||
|
||
namespace Kiota.Builder.OpenApiExtensions; | ||
|
||
public class OpenApiLegalInfoUrlExtension : OpenApiSimpleStringExtension | ||
{ | ||
public static string Name => "x-legal-info-url"; | ||
public string? Legal | ||
{ | ||
get; set; | ||
} | ||
protected override string? ValueSelector => Legal; | ||
public static OpenApiLegalInfoUrlExtension Parse(IOpenApiAny source) | ||
{ | ||
return new OpenApiLegalInfoUrlExtension | ||
{ | ||
Legal = ParseString(source) | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Kiota.Builder/OpenApiExtensions/OpenApiLogoExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.OpenApi.Any; | ||
|
||
namespace Kiota.Builder.OpenApiExtensions; | ||
|
||
public class OpenApiLogoExtension : OpenApiSimpleStringExtension | ||
{ | ||
public static string Name => "x-logo"; | ||
public string? Logo | ||
{ | ||
get; set; | ||
} | ||
protected override string? ValueSelector => Logo; | ||
public static OpenApiLogoExtension Parse(IOpenApiAny source) | ||
{ | ||
return new OpenApiLogoExtension | ||
{ | ||
Logo = ParseString(source) | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Kiota.Builder/OpenApiExtensions/OpenApiPrivacyPolicyUrlExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.OpenApi.Any; | ||
|
||
namespace Kiota.Builder.OpenApiExtensions; | ||
|
||
public class OpenApiPrivacyPolicyUrlExtension : OpenApiSimpleStringExtension | ||
{ | ||
public static string Name => "x-privacy-policy-url"; | ||
public string? Privacy | ||
{ | ||
get; set; | ||
} | ||
protected override string? ValueSelector => Privacy; | ||
public static OpenApiPrivacyPolicyUrlExtension Parse(IOpenApiAny source) | ||
{ | ||
return new OpenApiPrivacyPolicyUrlExtension | ||
{ | ||
Privacy = ParseString(source) | ||
}; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Kiota.Builder/OpenApiExtensions/OpenApiSimpleStringExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using Microsoft.OpenApi; | ||
using Microsoft.OpenApi.Any; | ||
using Microsoft.OpenApi.Interfaces; | ||
using Microsoft.OpenApi.Writers; | ||
|
||
namespace Kiota.Builder.OpenApiExtensions; | ||
|
||
public abstract class OpenApiSimpleStringExtension : IOpenApiExtension | ||
{ | ||
protected abstract string? ValueSelector | ||
{ | ||
get; | ||
} | ||
public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) | ||
{ | ||
ArgumentNullException.ThrowIfNull(writer); | ||
if (!string.IsNullOrWhiteSpace(ValueSelector)) | ||
{ | ||
writer.WriteValue(ValueSelector); | ||
} | ||
} | ||
public static string ParseString(IOpenApiAny source) | ||
{ | ||
if (source is not OpenApiString rawString) throw new ArgumentOutOfRangeException(nameof(source)); | ||
return rawString.Value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters