本文整理汇总了C#中Newtonsoft.Json.Linq.JArray.Parameter方法的典型用法代码示例。如果您正苦于以下问题:C# JArray.Parameter方法的具体用法?C# JArray.Parameter怎么用?C# JArray.Parameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JArray
的用法示例。
在下文中一共展示了JArray.Parameter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSwaggerPathForEntity
/// <summary>
/// Create the Swagger path for the Edm entity.
/// </summary>
/// <param name="navigationSource">The Edm navigation source.</param>
/// <returns>The <see cref="Newtonsoft.Json.Linq.JObject"/> represents the related Edm entity.</returns>
public static JObject CreateSwaggerPathForEntity(IEdmNavigationSource navigationSource)
{
IEdmEntitySet entitySet = navigationSource as IEdmEntitySet;
if (entitySet == null)
{
return new JObject();
}
var keyParameters = new JArray();
foreach (var key in entitySet.EntityType().Key())
{
string format;
string type = GetPrimitiveTypeAndFormat(key.Type.Definition as IEdmPrimitiveType, out format);
keyParameters.Parameter(key.Name, "path", "key: " + key.Name, type, format);
}
return new JObject()
{
{
"get", new JObject()
.Summary("Get entity from " + entitySet.Name + " by key.")
.OperationId(entitySet.Name + "_GetById")
.Description("Returns the entity with the key from " + entitySet.Name)
.Tags(entitySet.Name)
.Parameters((keyParameters.DeepClone() as JArray)
.Parameter("$select", "query", "description", "string"))
.Responses(new JObject()
.Response("200", "EntitySet " + entitySet.Name, entitySet.EntityType())
.DefaultErrorResponse())
},
{
"patch", new JObject()
.Summary("Update entity in EntitySet " + entitySet.Name)
.OperationId(entitySet.Name + "_PatchById")
.Description("Update entity in EntitySet " + entitySet.Name)
.Tags(entitySet.Name)
.Parameters((keyParameters.DeepClone() as JArray)
.Parameter(entitySet.EntityType().Name, "body", "The entity to patch",
entitySet.EntityType()))
.Responses(new JObject()
.Response("204", "Empty response")
.DefaultErrorResponse())
},
{
"delete", new JObject()
.Summary("Delete entity in EntitySet " + entitySet.Name)
.OperationId(entitySet.Name + "_DeleteById")
.Description("Delete entity in EntitySet " + entitySet.Name)
.Tags(entitySet.Name)
.Parameters((keyParameters.DeepClone() as JArray)
.Parameter("If-Match", "header", "If-Match header", "string"))
.Responses(new JObject()
.Response("204", "Empty response")
.DefaultErrorResponse())
}
};
}
示例2: CreateSwaggerPathForOperationOfEntitySet
static JObject CreateSwaggerPathForOperationOfEntitySet(IEdmOperation operation, IEdmEntitySet entitySet)
{
JArray swaggerParameters = new JArray();
foreach (var parameter in operation.Parameters.Skip(1))
{
swaggerParameters.Parameter(parameter.Name, operation is IEdmFunction ? "path" : "body",
"parameter: " + parameter.Name, parameter.Type.Definition);
}
JObject swaggerResponses = new JObject();
if (operation.ReturnType == null)
{
swaggerResponses.Response("204", "Empty response");
}
else
{
swaggerResponses.Response("200", "Response from " + operation.Name,
operation.ReturnType.Definition);
}
JObject swaggerOperation = new JObject()
.Summary("Call operation " + operation.Name)
.Description("Call operation " + operation.Name)
.Tags(entitySet.Name, operation is IEdmFunction ? "Function" : "Action");
if (swaggerParameters.Count > 0)
{
swaggerOperation.Parameters(swaggerParameters);
}
swaggerOperation.Responses(swaggerResponses.DefaultErrorResponse());
return new JObject()
{
{operation is IEdmFunction ? "get" : "post", swaggerOperation}
};
}
示例3: CreateSwaggerPathForOperationImport
/// <summary>
/// Create the Swagger path for the Edm operation import.
/// </summary>
/// <param name="operationImport">The Edm operation import</param>
/// <returns>The <see cref="Newtonsoft.Json.Linq.JObject"/> represents the related Edm operation import.</returns>
public static JObject CreateSwaggerPathForOperationImport(IEdmOperationImport operationImport)
{
if (operationImport == null)
{
return new JObject();
}
bool isFunctionImport = operationImport is IEdmFunctionImport;
JArray swaggerParameters = new JArray();
foreach (var parameter in operationImport.Operation.Parameters)
{
swaggerParameters.Parameter(parameter.Name, isFunctionImport ? "path" : "body",
"parameter: " + parameter.Name, parameter.Type.Definition);
}
JObject swaggerResponses = new JObject();
if (operationImport.Operation.ReturnType == null)
{
swaggerResponses.Response("204", "Empty response");
}
else
{
swaggerResponses.Response("200", "Response from " + operationImport.Name,
operationImport.Operation.ReturnType.Definition);
}
JObject swaggerOperationImport = new JObject()
.Summary("Call operation import " + operationImport.Name)
.OperationId(operationImport.Name + (isFunctionImport ? "_FunctionImportGet" : "_ActionImportPost"))
.Description("Call operation import " + operationImport.Name)
.Tags(isFunctionImport ? "Function Import" : "Action Import");
if (swaggerParameters.Count > 0)
{
swaggerOperationImport.Parameters(swaggerParameters);
}
swaggerOperationImport.Responses(swaggerResponses.DefaultErrorResponse());
return new JObject()
{
{ isFunctionImport ? "get" : "post", swaggerOperationImport }
};
}
示例4: CreateSwaggerPathForOperationOfEntity
/// <summary>
/// Create the Swagger path for the Edm operation bound to the Edm entity.
/// </summary>
/// <param name="operation">The Edm operation.</param>
/// <param name="navigationSource">The Edm navigation source.</param>
/// <returns>The <see cref="Newtonsoft.Json.Linq.JObject"/> represents the related Edm operation bound to the Edm entity.</returns>
public static JObject CreateSwaggerPathForOperationOfEntity(IEdmOperation operation, IEdmNavigationSource navigationSource)
{
IEdmEntitySet entitySet = navigationSource as IEdmEntitySet;
if (operation == null || entitySet == null)
{
return new JObject();
}
bool isFunction = operation is IEdmFunction;
JArray swaggerParameters = new JArray();
foreach (var key in entitySet.EntityType().Key())
{
string format;
string type = GetPrimitiveTypeAndFormat(key.Type.Definition as IEdmPrimitiveType, out format);
swaggerParameters.Parameter(key.Name, "path", "key: " + key.Name, type, format);
}
foreach (var parameter in operation.Parameters.Skip(1))
{
swaggerParameters.Parameter(parameter.Name, isFunction ? "path" : "body",
"parameter: " + parameter.Name, parameter.Type.Definition);
}
JObject swaggerResponses = new JObject();
if (operation.ReturnType == null)
{
swaggerResponses.Response("204", "Empty response");
}
else
{
swaggerResponses.Response("200", "Response from " + operation.Name,
operation.ReturnType.Definition);
}
JObject swaggerOperation = new JObject()
.Summary("Call operation " + operation.Name)
.OperationId(operation.Name + (isFunction ? "_FunctionGetById" : "_ActionPostById"))
.Description("Call operation " + operation.Name)
.Tags(entitySet.Name, isFunction ? "Function" : "Action");
if (swaggerParameters.Count > 0)
{
swaggerOperation.Parameters(swaggerParameters);
}
swaggerOperation.Responses(swaggerResponses.DefaultErrorResponse());
return new JObject()
{
{ isFunction ? "get" : "post", swaggerOperation }
};
}
示例5: CreateSwaggerPathForOperationOfEntity
static JObject CreateSwaggerPathForOperationOfEntity(IEdmOperation operation, IEdmEntitySet entitySet)
{
JArray swaggerParameters = new JArray();
foreach (var key in entitySet.EntityType().Key())
{
string format;
string type = GetPrimitiveTypeAndFormat(key.Type.Definition as IEdmPrimitiveType, out format);
bool required = !key.Type.IsNullable ;
swaggerParameters.Parameter(key.Name, "path", "key: " + key.Name, type, format, required);
}
foreach (var parameter in operation.Parameters.Skip(1))
{
swaggerParameters.Parameter(parameter.Name, operation is IEdmFunction ? "path" : "body",
"parameter: " + parameter.Name, parameter.Type.Definition);
}
JObject swaggerResponses = new JObject();
if (operation.ReturnType == null)
{
swaggerResponses.Response("204", "Empty response");
}
else
{
swaggerResponses.Response("200", "Response from " + operation.Name,
operation.ReturnType.Definition);
}
JObject swaggerOperation = new JObject()
.Summary("Call operation " + operation.Name)
.Description("Call operation " + operation.Name)
.Tags(entitySet.Name, operation is IEdmFunction ? "Function" : "Action");
if (swaggerParameters.Count > 0)
{
swaggerOperation.Parameters(swaggerParameters);
}
swaggerOperation.Responses(swaggerResponses.DefaultErrorResponse());
return new JObject()
{
{operation is IEdmFunction ? "get" : "post", swaggerOperation}
};
}