Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ public static OpenApiAiAdaptiveCardExtension Parse(JsonNode source)
public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
{
ArgumentNullException.ThrowIfNull(writer);
writer.WriteStartObject();
// Only write the object if there's actual content to write
if (!string.IsNullOrEmpty(DataPath) && !string.IsNullOrEmpty(File) && !string.IsNullOrEmpty(Title))
{
writer.WriteStartObject();
writer.WritePropertyName(nameof(DataPath).ToFirstCharacterLowerCase().ToSnakeCase());
writer.WriteValue(DataPath);
writer.WritePropertyName(nameof(File).ToFirstCharacterLowerCase());
Expand All @@ -77,7 +78,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
writer.WritePropertyName(nameof(Url).ToFirstCharacterLowerCase());
writer.WriteValue(Url);
}
writer.WriteEndObject();
}
writer.WriteEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ public static OpenApiAiCapabilitiesExtension Parse(JsonNode source)
public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
{
ArgumentNullException.ThrowIfNull(writer);
writer.WriteStartObject();
// Only write the object if there's actual content to write
if (ResponseSemantics != null || Confirmation != null || SecurityInfo != null)
{
writer.WriteStartObject();

if (ResponseSemantics is not null)
{
Expand All @@ -64,8 +65,9 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
writer.WritePropertyName(nameof(SecurityInfo).ToFirstCharacterLowerCase().ToSnakeCase());
WriteSecurityInfo(writer, SecurityInfo);
}

writer.WriteEndObject();
}
writer.WriteEndObject();
}

private static ExtensionConfirmation ParseConfirmation(JsonObject source)
Expand Down
5 changes: 3 additions & 2 deletions src/Kiota.Builder/OpenApiExtensions/OpenApiLogoExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ public static OpenApiLogoExtension Parse(JsonNode source)
public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
{
ArgumentNullException.ThrowIfNull(writer);
writer.WriteStartObject();
// Only write the object if there's actual content to write
if (!string.IsNullOrEmpty(Url))
{
writer.WriteStartObject();
writer.WritePropertyName(nameof(Url).ToFirstCharacterLowerCase());
writer.WriteValue(Url);
writer.WriteEndObject();
}
writer.WriteEndObject();
}
}
8 changes: 7 additions & 1 deletion src/Kiota.Builder/Plugins/PluginsGenerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ rExtRaw is T rExt &&
capabilitiesExtension is OpenApiAiCapabilitiesExtension capabilities)
{
var functionCapabilities = new FunctionCapabilities();
bool hasContent = false;

// Set ResponseSemantics
if (capabilities.ResponseSemantics is not null)
Expand Down Expand Up @@ -1163,6 +1164,7 @@ rExtRaw is T rExt &&
}
responseSemantics.OAuthCardPath = capabilities.ResponseSemantics.OauthCardPath;
functionCapabilities.ResponseSemantics = responseSemantics;
hasContent = true;
}

// Set Confirmation
Expand All @@ -1175,6 +1177,7 @@ rExtRaw is T rExt &&
Body = capabilities.Confirmation.Body,
};
functionCapabilities.Confirmation = confirmation;
hasContent = true;
}

// Set SecurityInfo
Expand All @@ -1185,8 +1188,11 @@ rExtRaw is T rExt &&
DataHandling = capabilities.SecurityInfo.DataHandling,
};
functionCapabilities.SecurityInfo = securityInfo;
hasContent = true;
}
return functionCapabilities;

// Only return the capabilities object if it actually has content
return hasContent ? functionCapabilities : null;
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ public void GetSchemaNameAnyOfReference()
{
AnyOf = [
new OpenApiSchemaReference("microsoft.graph.entity"),
new OpenApiSchemaReference("microsoft.graph.user"),
]
new OpenApiSchemaReference("microsoft.graph.user"),
]
};
var names = schema.GetSchemaNames();
Assert.Contains("entity", names);
Expand Down Expand Up @@ -233,8 +233,8 @@ public void GetSchemaNameOneOfReference()
{
OneOf = [
new OpenApiSchemaReference("microsoft.graph.entity"),
new OpenApiSchemaReference("microsoft.graph.user"),
]
new OpenApiSchemaReference("microsoft.graph.user"),
]
};
var names = schema.GetSchemaNames();
Assert.Contains("entity", names);
Expand Down Expand Up @@ -315,7 +315,8 @@ public void GetReferenceIdsAllOfNested()
var schema = new OpenApiSchema
{
AllOf = [
new OpenApiSchema() {
new OpenApiSchema()
{
AllOf = [
new OpenApiSchemaReference("microsoft.graph.entity"),
new OpenApiSchemaReference("microsoft.graph.user")
Expand Down Expand Up @@ -388,9 +389,11 @@ public void IsInherited()
{
AllOf = [
new OpenApiSchemaReference("microsoft.graph.entity"),
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, IOpenApiSchema>() {
Properties = new Dictionary<string, IOpenApiSchema>()
{
["firstName"] = new OpenApiSchema()
}
}
Expand Down Expand Up @@ -441,15 +444,19 @@ public void IsIntersection()
schema = new OpenApiSchema
{
AllOf = [
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, IOpenApiSchema>() {
Properties = new Dictionary<string, IOpenApiSchema>()
{
["id"] = new OpenApiSchema()
}
},
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, IOpenApiSchema>() {
Properties = new Dictionary<string, IOpenApiSchema>()
{
["firstName"] = new OpenApiSchema()
}
}
Expand All @@ -461,9 +468,11 @@ public void IsIntersection()
schema = new OpenApiSchema
{
AllOf = [
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, IOpenApiSchema>() {
Properties = new Dictionary<string, IOpenApiSchema>()
{
["id"] = new OpenApiSchema()
}
}
Expand Down Expand Up @@ -503,15 +512,19 @@ public void MergesIntersection()
Description = "description",
Deprecated = true,
AllOf = [
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, IOpenApiSchema>() {
Properties = new Dictionary<string, IOpenApiSchema>()
{
["id"] = new OpenApiSchema()
}
},
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, IOpenApiSchema>() {
Properties = new Dictionary<string, IOpenApiSchema>()
{
["firstName"] = new OpenApiSchema()
}
}
Expand All @@ -533,25 +546,32 @@ public void MergesIntersectionRecursively()
Description = "description",
Deprecated = true,
AllOf = [
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, IOpenApiSchema>() {
Properties = new Dictionary<string, IOpenApiSchema>()
{
["id"] = new OpenApiSchema()
}
},
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
AllOf = [
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, IOpenApiSchema>() {
Properties = new Dictionary<string, IOpenApiSchema>()
{
["firstName"] = new OpenApiSchema(),
["lastName"] = new OpenApiSchema()
}
},
new OpenApiSchema() {
new OpenApiSchema()
{
Type = JsonSchemaType.Object,
Properties = new Dictionary<string, IOpenApiSchema>() {
Properties = new Dictionary<string, IOpenApiSchema>()
{
["lastName"] = new OpenApiSchema()
}
},
Expand Down Expand Up @@ -947,11 +967,11 @@ public void IsEnumFailsOnEmptyMembers()
Enum =
[
"low",
"medium",
"high",
"hidden",
"none",
"unknownFutureValue"
"medium",
"high",
"hidden",
"none",
"unknownFutureValue"
],
Type = JsonSchemaType.String
};
Expand Down
Loading
Loading