我从一个swagger定义生成Jmeter的jmx文件,生成的JMX和测试数据CSV看起来很无用,它没有关于API期望的参数信息,没有响应映射信息的http状态代码等.
您可以获取任何定义文件,以重现此:
我期望的是具有API的整个框架的JMX,以便QA人员不必担心这一点并且只关注测试.
我为其他语言/工具生产的所有客户都足够好,除了Jmeter,我在这里做错了吗?
我正在为现有的API编写OpenAPI规范.此API为成功和失败返回状态200,但具有不同的响应结构.
例如,在注册API中,如果用户成功注册,则API会使用以下JSON发送状态200:
{
"result": true,
"token": RANDOM_STRING
}
Run Code Online (Sandbox Code Playgroud)
如果有重复的用户,API也会发送状态200,但使用以下JSON:
{
"result": false,
"errorCode": "00002", // this code is duplicated error
"errorMsg": "duplicated account already exist"
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,如何定义响应?
我正在尝试找到一个解决方案,使用一个快速应用程序拥有多个swaggerUi文档.
我正在使用 :
"typescript": "^2.5.2",
"swagger-tools": "^0.10.1",
"express": "^4.15.3",
"express-openapi": "^1.0.1",
Run Code Online (Sandbox Code Playgroud)
我的swagger doc文件部分是使用项目文件架构生成的.
我怎样才能做到这一点 ?
编辑---
现在我正在这样初始化swaggerUi:
const openapi = Openapi.initialize({
paths: openApiPaths,
expressApp,
swaggerApiDoc,
});
const openApiSpec: any = openapi.apiDoc;
app.use(swaggerUI(openApiSpec));
Run Code Online (Sandbox Code Playgroud)
哪里openApiPaths包含paths:{}swagger doc
我正在尝试使用OpenAPI记录看起来像的查询字符串
filtered[0][id]=code&filtered[0][value]=12345
Run Code Online (Sandbox Code Playgroud)
并包含具有属性id和的对象列表value。
我的yaml文档如下所示
parameters:
- name: filtered
in: query
description: filters to be applied
explode: true
style: deepObject
schema:
type: array
items:
properties:
id:
description: name of the field to be filtered
type: string
value:
description: value of the filter
type: object
Run Code Online (Sandbox Code Playgroud)
问题如下:看起来该style: deepObject选项仅适用于一个级别,而不适用于我的对象实际所在的第二个级别。也就是说,它需要一个查询字符串,例如
?sorted[0]=%7B%0A%20%20%22id%22%3A%20%22string%22%2C%0A%20%20%22value%22%3A%20true%0A%7D
Run Code Online (Sandbox Code Playgroud)
该对象未使用id和value键序列化为数组。
有办法解决吗?
似乎有许多专用于验证OpenApi模式正确性的python库。虽然这可能有用,但坦率地说,我可以在https://editor.swagger.io上在此处编写我的OpenApi模式,并对其进行验证/转换/格式化。
然后,我剩下的客户可能会向我的OpenApi记录的端点发送任何脏数据。
因此,我找不到的是一个提供了OpenApi模式和JSON(通常来自HTTP请求)的库,用于根据模式验证输入/数据JSON。所有必填字段都到位了吗?我希望age是一个数字,所以不要通过验证,因为它是作为字符串传递的,依此类推。
我能找到的最接近的东西是https://flask-restplus.readthedocs.io/en/stable/,但是
是否有任何Python库可以再次验证输入数据和OpenApi模式?
I have a huge @OpenApi annotation (basically it's documentation of a Javalin/Kotlin endpoint) which occupies a lot of lines:
@OpenApi(
summary = "",
description = "Lists all customers",
path = "customers",
queryParams =
// ...........
// ...........
// etc
)
override fun handle(context: Context) {
// body of the REST handler
}
Run Code Online (Sandbox Code Playgroud)
I have to scroll a lot to see the actual handler. Hence, I'd like to isolate it somehow like:
@GetCustomersDoc
override fun handle(context: Context) {
// body …Run Code Online (Sandbox Code Playgroud) 您好,我需要从结构推断 json 架构 (github.com/go-openapi/spec.Schema):
type Testcase struct {
Id string `json:"id,omitempty"` // id of this test case
Name string `json:"name,omitempty"` // name of this test case
CreationDate time.Time `json:"creation_date,omitempty"` // timestamp when the scenario was first created
UpdateDate time.Time `json:"update_date,omitempty"` // last update timestamp
Steps []Step `json:"steps,omitempty"` // list of steps type:"[]StepCcs"
}
Run Code Online (Sandbox Code Playgroud)
我找不到简单的方法来做到这一点。我想这是许多从代码生成开放 API 规范的 REST 框架的先决条件。
有人可以向我指出包含此类助手的包吗:即
func toSchema(obj interface{}) (spec.Schema, error)
Run Code Online (Sandbox Code Playgroud) 我有一个新的 .NET6 Azure Functions 应用程序。我使用 OpenAPI 规范创建了一些 HTTP 函数。
我的 swagger 页面工作正常,除了 POST 功能。
我想在此页面上显示一个最小的正文请求作为示例。
我已经IOpenApiExample按照https://github.com/Azure/azure-functions-openapi-extension/blob/main/docs/openapi-core.md#openapirequestbodyattribute
中提到的方式实现了
,但未使用该示例。它不断显示整个模型,没有任何样本值。
这是我的相关代码:
[FunctionName("PostHistoryEvent")]
[OpenApiOperation(operationId: "PostHistoryEvent", tags: new[] { "Post HistoryEvent" })]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiRequestBody("application/json", typeof(HistoryEvent), Required = true, Description = "Description of OpenApiRequestBody", Example = typeof(HistoryEventOpenApiExample))]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.Created, contentType: "application/json", bodyType: typeof(HistoryEvent), Description = "The created History Event")]
public async Task<IActionResult> PostHistoryEvent(...){...}
public class HistoryEventOpenApiExample : OpenApiExample<HistoryEvent>
{
public override IOpenApiExample<HistoryEvent> Build(NamingStrategy namingStrategy = …Run Code Online (Sandbox Code Playgroud) 我需要 JSON 方案中的一个字段为日期或日期时间。它可以具有这些格式中的任何一种。使用该format属性,是否可以使用两种格式?
我正在使用 OpenAPI / Swagger 来指定我的 API。
我不知道的一件事是如何指定一个集合。
我正在使用https://editor.swagger.io/并输入了整个 API。对于我想指定为 Set 的属性,我编写了以下内容:
myProperty:
uniqueItems: true
type: array
description: some description
items:
type: string
Run Code Online (Sandbox Code Playgroud)
我猜想uniqueItems可以解决问题并生成一个 Set,但事实并非如此。相反,会生成以下代码:
@JsonProperty("myProperty")
private List<String> myProperty = null;
Run Code Online (Sandbox Code Playgroud)
有没有办法生成类似的东西
@JsonProperty("myProperty")
private Set<String> myProperty = null;
Run Code Online (Sandbox Code Playgroud)
反而?
我在 SO 中找到了一个可能的解决方案,但这需要在 pom.xml 中进行一些配置。然而,我使用的在线编辑器只提供了为不同平台生成代码的选项,但不接受 pom 文件。
openapi ×10
swagger ×7
java ×2
jsonschema ×2
annotations ×1
express ×1
go ×1
javalin ×1
jmeter ×1
json ×1
kotlin ×1
node.js ×1
python ×1
rest ×1
swagger-ui ×1
typescript ×1