本文整理汇总了C#中Newtonsoft.Json.Linq.JObject.Response方法的典型用法代码示例。如果您正苦于以下问题:C# JObject.Response方法的具体用法?C# JObject.Response怎么用?C# JObject.Response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JObject
的用法示例。
在下文中一共展示了JObject.Response方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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}
};
}
示例2: 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 }
};
}
示例3: 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 }
};
}
示例4: 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}
};
}