Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ internal static partial class RestApiOperationExtensions
/// the parameters 'sender.email' and 'receiver.mail' will be correctly resolved from arguments with the same names.
/// </param>
/// <returns>The list of parameters.</returns>
public static IReadOnlyList<RestApiOperationParameter> GetParameters(
public static IReadOnlyList<RestApiParameter> GetParameters(
this RestApiOperation operation,
bool addPayloadParamsFromMetadata = true,
bool enablePayloadNamespacing = false)
{
var parameters = new List<RestApiOperationParameter>(operation.Parameters);
var parameters = new List<RestApiParameter>(operation.Parameters);

// Add payload parameters
if (operation.Payload is not null)
Expand All @@ -55,7 +55,7 @@ public static IReadOnlyList<RestApiOperationParameter> GetParameters(
/// <returns>The default return parameter metadata, if any.</returns>
public static KernelReturnParameterMetadata? GetDefaultReturnParameter(this RestApiOperation operation, string[]? preferredResponses = null)
{
RestApiOperationExpectedResponse? restOperationResponse = GetDefaultResponse(operation.Responses, preferredResponses ??= s_preferredResponses);
RestApiExpectedResponse? restOperationResponse = GetDefaultResponse(operation.Responses, preferredResponses ??= s_preferredResponses);

var returnParameter =
restOperationResponse is not null ? new KernelReturnParameterMetadata { Description = restOperationResponse.Description, Schema = restOperationResponse.Schema } : null;
Expand All @@ -69,7 +69,7 @@ public static IReadOnlyList<RestApiOperationParameter> GetParameters(
/// <param name="responses">The REST API operation responses to parse.</param>
/// <param name="preferredResponses">The preferred response codes to use when selecting the default response.</param>
/// <returns>The default response, if any.</returns>
private static RestApiOperationExpectedResponse? GetDefaultResponse(IReadOnlyDictionary<string, RestApiOperationExpectedResponse> responses, string[] preferredResponses)
private static RestApiExpectedResponse? GetDefaultResponse(IReadOnlyDictionary<string, RestApiExpectedResponse> responses, string[] preferredResponses)
{
foreach (var code in preferredResponses)
{
Expand All @@ -90,8 +90,8 @@ public static IReadOnlyList<RestApiOperationParameter> GetParameters(
/// <param name="useParametersFromMetadata">Flag indicating whether to include parameters from metadata.
/// If false or not specified, the 'payload' and 'content-type' parameters are added instead.</param>
/// <param name="enableNamespacing">Flag indicating whether to namespace payload parameter names.</param>
/// <returns>A list of <see cref="RestApiOperationParameter"/> representing the payload parameters.</returns>
private static List<RestApiOperationParameter> GetPayloadParameters(RestApiOperation operation, bool useParametersFromMetadata, bool enableNamespacing)
/// <returns>A list of <see cref="RestApiParameter"/> representing the payload parameters.</returns>
private static List<RestApiParameter> GetPayloadParameters(RestApiOperation operation, bool useParametersFromMetadata, bool enableNamespacing)
{
if (useParametersFromMetadata)
{
Expand Down Expand Up @@ -122,15 +122,15 @@ private static List<RestApiOperationParameter> GetPayloadParameters(RestApiOpera
/// </summary>
/// <param name="operation">The REST API operation.</param>
/// <returns>The 'content-type' artificial parameter.</returns>
private static RestApiOperationParameter CreateContentTypeArtificialParameter(RestApiOperation operation)
private static RestApiParameter CreateContentTypeArtificialParameter(RestApiOperation operation)
{
return new RestApiOperationParameter(
return new RestApiParameter(
RestApiOperation.ContentTypeArgumentName,
"string",
isRequired: false,
expand: false,
RestApiOperationParameterLocation.Body,
RestApiOperationParameterStyle.Simple,
RestApiParameterLocation.Body,
RestApiParameterStyle.Simple,
description: "Content type of REST API request body.");
}

Expand All @@ -139,15 +139,15 @@ private static RestApiOperationParameter CreateContentTypeArtificialParameter(Re
/// </summary>
/// <param name="operation">The REST API operation.</param>
/// <returns>The 'payload' artificial parameter.</returns>
private static RestApiOperationParameter CreatePayloadArtificialParameter(RestApiOperation operation)
private static RestApiParameter CreatePayloadArtificialParameter(RestApiOperation operation)
{
return new RestApiOperationParameter(
return new RestApiParameter(
RestApiOperation.PayloadArgumentName,
operation.Payload?.MediaType == MediaTypeTextPlain ? "string" : "object",
isRequired: true,
expand: false,
RestApiOperationParameterLocation.Body,
RestApiOperationParameterStyle.Simple,
RestApiParameterLocation.Body,
RestApiParameterStyle.Simple,
description: operation.Payload?.Description ?? "REST API request body.",
schema: operation.Payload?.Schema);
}
Expand All @@ -161,23 +161,23 @@ private static RestApiOperationParameter CreatePayloadArtificialParameter(RestAp
/// </param>
/// <param name="rootPropertyName">The root property name.</param>
/// <returns>The list of payload parameters.</returns>
private static List<RestApiOperationParameter> GetParametersFromPayloadMetadata(IReadOnlyList<RestApiOperationPayloadProperty> properties, bool enableNamespacing = false, string? rootPropertyName = null)
private static List<RestApiParameter> GetParametersFromPayloadMetadata(IReadOnlyList<RestApiPayloadProperty> properties, bool enableNamespacing = false, string? rootPropertyName = null)
{
var parameters = new List<RestApiOperationParameter>();
var parameters = new List<RestApiParameter>();

foreach (var property in properties)
{
var parameterName = GetPropertyName(property, rootPropertyName, enableNamespacing);

if (!property.Properties.Any())
{
parameters.Add(new RestApiOperationParameter(
parameters.Add(new RestApiParameter(
name: parameterName,
type: property.Type,
isRequired: property.IsRequired,
expand: false,
location: RestApiOperationParameterLocation.Body,
style: RestApiOperationParameterStyle.Simple,
location: RestApiParameterLocation.Body,
style: RestApiParameterStyle.Simple,
defaultValue: property.DefaultValue,
description: property.Description,
format: property.Format,
Expand All @@ -197,7 +197,7 @@ private static List<RestApiOperationParameter> GetParametersFromPayloadMetadata(
/// <param name="rootPropertyName">The root property name to be used for constructing the full property name.</param>
/// <param name="enableNamespacing">Determines whether to add namespace to property name or not.</param>
/// <returns>The property name.</returns>
private static string GetPropertyName(RestApiOperationPayloadProperty property, string? rootPropertyName, bool enableNamespacing = false)
private static string GetPropertyName(RestApiPayloadProperty property, string? rootPropertyName, bool enableNamespacing = false)
{
if (enableNamespacing)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ namespace Microsoft.SemanticKernel.Plugins.OpenApi;
/// <param name="payload">The operation payload metadata.</param>
/// <param name="arguments">The operation arguments.</param>
/// <returns>The object and HttpContent representing the operation payload.</returns>
internal delegate (object? Payload, HttpContent Content) HttpContentFactory(RestApiOperationPayload? payload, IDictionary<string, object?> arguments);
internal delegate (object? Payload, HttpContent Content) HttpContentFactory(RestApiPayload? payload, IDictionary<string, object?> arguments);
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace Microsoft.SemanticKernel.Plugins.OpenApi;

/// <summary>
/// The REST API operation response.
/// REST API response.
/// </summary>
[Experimental("SKEXP0040")]
public sealed class RestApiOperationExpectedResponse
public sealed class RestApiExpectedResponse
{
/// <summary>
/// Gets the description of the response.
Expand All @@ -26,12 +26,12 @@ public sealed class RestApiOperationExpectedResponse
public KernelJsonSchema? Schema { get; }

/// <summary>
/// Initializes a new instance of the <see cref="RestApiOperationResponse"/> class.
/// Initializes a new instance of the <see cref="RestApiExpectedResponse"/> class.
/// </summary>
/// <param name="description">The description of the response.</param>
/// <param name="mediaType">The media type of the response.</param>
/// <param name="schema">The schema against which the response body should be validated.</param>
internal RestApiOperationExpectedResponse(string description, string mediaType, KernelJsonSchema? schema = null)
internal RestApiExpectedResponse(string description, string mediaType, KernelJsonSchema? schema = null)
{
this.Description = description;
this.MediaType = mediaType;
Expand Down
40 changes: 20 additions & 20 deletions dotnet/src/Functions/Functions.OpenApi/Model/RestApiOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ public sealed class RestApiOperation
/// <summary>
/// The server.
/// </summary>
public IReadOnlyList<RestApiOperationServer> Servers { get; }
public IReadOnlyList<RestApiServer> Servers { get; }

/// <summary>
/// The operation parameters.
/// </summary>
public IReadOnlyList<RestApiOperationParameter> Parameters { get; }
public IReadOnlyList<RestApiParameter> Parameters { get; }

/// <summary>
/// The list of possible operation responses.
/// </summary>
public IReadOnlyDictionary<string, RestApiOperationExpectedResponse> Responses { get; }
public IReadOnlyDictionary<string, RestApiExpectedResponse> Responses { get; }

/// <summary>
/// The operation payload.
/// </summary>
public RestApiOperationPayload? Payload { get; }
public RestApiPayload? Payload { get; }

/// <summary>
/// Additional unstructured metadata about the operation.
Expand All @@ -89,13 +89,13 @@ public sealed class RestApiOperation
/// <param name="responses">The operation responses.</param>
internal RestApiOperation(
string id,
IReadOnlyList<RestApiOperationServer> servers,
IReadOnlyList<RestApiServer> servers,
string path,
HttpMethod method,
string description,
IReadOnlyList<RestApiOperationParameter> parameters,
RestApiOperationPayload? payload = null,
IReadOnlyDictionary<string, RestApiOperationExpectedResponse>? responses = null)
IReadOnlyList<RestApiParameter> parameters,
RestApiPayload? payload = null,
IReadOnlyDictionary<string, RestApiExpectedResponse>? responses = null)
{
this.Id = id;
this.Servers = servers;
Expand All @@ -104,7 +104,7 @@ internal RestApiOperation(
this.Description = description;
this.Parameters = parameters;
this.Payload = payload;
this.Responses = responses ?? new Dictionary<string, RestApiOperationExpectedResponse>();
this.Responses = responses ?? new Dictionary<string, RestApiExpectedResponse>();
}

/// <summary>
Expand Down Expand Up @@ -132,7 +132,7 @@ internal IDictionary<string, string> BuildHeaders(IDictionary<string, object?> a
{
var headers = new Dictionary<string, string>();

var parameters = this.Parameters.Where(p => p.Location == RestApiOperationParameterLocation.Header);
var parameters = this.Parameters.Where(p => p.Location == RestApiParameterLocation.Header);

foreach (var parameter in parameters)
{
Expand All @@ -148,7 +148,7 @@ internal IDictionary<string, string> BuildHeaders(IDictionary<string, object?> a
continue;
}

var parameterStyle = parameter.Style ?? RestApiOperationParameterStyle.Simple;
var parameterStyle = parameter.Style ?? RestApiParameterStyle.Simple;

if (!s_parameterSerializers.TryGetValue(parameterStyle, out var serializer))
{
Expand All @@ -173,7 +173,7 @@ internal string BuildQueryString(IDictionary<string, object?> arguments)
{
var segments = new List<string>();

var parameters = this.Parameters.Where(p => p.Location == RestApiOperationParameterLocation.Query);
var parameters = this.Parameters.Where(p => p.Location == RestApiParameterLocation.Query);

foreach (var parameter in parameters)
{
Expand All @@ -189,7 +189,7 @@ internal string BuildQueryString(IDictionary<string, object?> arguments)
continue;
}

var parameterStyle = parameter.Style ?? RestApiOperationParameterStyle.Form;
var parameterStyle = parameter.Style ?? RestApiParameterStyle.Form;

if (!s_parameterSerializers.TryGetValue(parameterStyle, out var serializer))
{
Expand All @@ -215,7 +215,7 @@ internal string BuildQueryString(IDictionary<string, object?> arguments)
/// <returns>The path.</returns>
private string BuildPath(string pathTemplate, IDictionary<string, object?> arguments)
{
var parameters = this.Parameters.Where(p => p.Location == RestApiOperationParameterLocation.Path);
var parameters = this.Parameters.Where(p => p.Location == RestApiParameterLocation.Path);

foreach (var parameter in parameters)
{
Expand All @@ -231,7 +231,7 @@ private string BuildPath(string pathTemplate, IDictionary<string, object?> argum
continue;
}

var parameterStyle = parameter.Style ?? RestApiOperationParameterStyle.Simple;
var parameterStyle = parameter.Style ?? RestApiParameterStyle.Simple;

if (!s_parameterSerializers.TryGetValue(parameterStyle, out var serializer))
{
Expand Down Expand Up @@ -299,12 +299,12 @@ private Uri GetServerUrl(Uri? serverUrlOverride, Uri? apiHostUrl, IDictionary<st
return new Uri(serverUrlString);
}

private static readonly Dictionary<RestApiOperationParameterStyle, Func<RestApiOperationParameter, JsonNode, string>> s_parameterSerializers = new()
private static readonly Dictionary<RestApiParameterStyle, Func<RestApiParameter, JsonNode, string>> s_parameterSerializers = new()
{
{ RestApiOperationParameterStyle.Simple, SimpleStyleParameterSerializer.Serialize },
{ RestApiOperationParameterStyle.Form, FormStyleParameterSerializer.Serialize },
{ RestApiOperationParameterStyle.SpaceDelimited, SpaceDelimitedStyleParameterSerializer.Serialize },
{ RestApiOperationParameterStyle.PipeDelimited, PipeDelimitedStyleParameterSerializer.Serialize }
{ RestApiParameterStyle.Simple, SimpleStyleParameterSerializer.Serialize },
{ RestApiParameterStyle.Form, FormStyleParameterSerializer.Serialize },
{ RestApiParameterStyle.SpaceDelimited, SpaceDelimitedStyleParameterSerializer.Serialize },
{ RestApiParameterStyle.PipeDelimited, PipeDelimitedStyleParameterSerializer.Serialize }
};

# endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace Microsoft.SemanticKernel.Plugins.OpenApi;

/// <summary>
/// The REST API operation parameter.
/// REST API parameter.
/// </summary>
[Experimental("SKEXP0040")]
public sealed class RestApiOperationParameter
public sealed class RestApiParameter
{
/// <summary>
/// The parameter name.
Expand All @@ -23,7 +23,7 @@ public sealed class RestApiOperationParameter
/// <summary>
/// The parameter type - string, integer, number, boolean, array and object.
/// </summary>
public string Type { get; }
internal string Type { get; }

/// <summary>
/// The parameter type modifier that refines the generic parameter type to a more specific one.
Expand All @@ -44,17 +44,17 @@ public sealed class RestApiOperationParameter
/// <summary>
/// The parameter location.
/// </summary>
public RestApiOperationParameterLocation Location { get; }
public RestApiParameterLocation Location { get; }

/// <summary>
/// The parameter style - defines how multiple values are delimited.
/// </summary>
public RestApiOperationParameterStyle? Style { get; }
public RestApiParameterStyle? Style { get; }

/// <summary>
/// Type of array item for parameters of "array" type.
/// </summary>
public string? ArrayItemType { get; }
internal string? ArrayItemType { get; }

/// <summary>
/// The default value.
Expand All @@ -72,7 +72,7 @@ public sealed class RestApiOperationParameter
public KernelJsonSchema? Schema { get; }

/// <summary>
/// Creates an instance of a <see cref="RestApiOperationParameter"/> class.
/// Creates an instance of a <see cref="RestApiParameter"/> class.
/// </summary>
/// <param name="name">The parameter name.</param>
/// <param name="type">The parameter type.</param>
Expand All @@ -86,13 +86,13 @@ public sealed class RestApiOperationParameter
/// <param name="format">The parameter type modifier that refines the generic parameter type to a more specific one.
/// More details can be found at https://swagger.io/docs/specification/data-models/data-types</param>
/// <param name="schema">The parameter schema.</param>
internal RestApiOperationParameter(
internal RestApiParameter(
string name,
string type,
bool isRequired,
bool expand,
RestApiOperationParameterLocation location,
RestApiOperationParameterStyle? style = null,
RestApiParameterLocation location,
RestApiParameterStyle? style = null,
string? arrayItemType = null,
object? defaultValue = null,
string? description = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace Microsoft.SemanticKernel.Plugins.OpenApi;

/// <summary>
/// The REST API operation parameter location.
/// REST API parameter location.
/// </summary>
[Experimental("SKEXP0040")]
public enum RestApiOperationParameterLocation
public enum RestApiParameterLocation
{
/// <summary>
/// Query parameter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace Microsoft.SemanticKernel.Plugins.OpenApi;

/// <summary>
/// The REST API operation parameter style.
/// REST API operation parameter style.
/// </summary>
[Experimental("SKEXP0040")]
public enum RestApiOperationParameterStyle
public enum RestApiParameterStyle
{
/// <summary>
/// Path-style parameters.
Expand Down
Loading
Loading