我从一个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) 我想用 OpenApi 注释来装饰我的 azure c# 函数。该函数接受 JSON 模式作为参数。如何在注释中提及这一点。
想知道如何配置下面的注释
[OpenApiRequestBody(contentType: "json", bodyType: typeof(System.Text.Json.JsonDocument), Description = "Parameters",Example =typeof(Parameters))]
public class ModifyOrder
{
[FunctionName("ModifyOrder")]
[OpenApiOperation(operationId: "run", tags: new[] { "Modify Order" })]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiRequestBody(contentType: "json", bodyType: typeof(System.Text.Json.JsonDocument), Description = "Parameters",Example =typeof(Parameters))]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(string), Description = "The OK response")]
public static async Task<IActionResult> run(
[HttpTrigger(AuthorizationLevel.Function, "put", Route = null )] HttpRequest req,
ILogger log)
{
log.LogInformation($"C# HTTP trigger function processed a request."); …Run Code Online (Sandbox Code Playgroud) I\xe2\x80\x99m 尝试在 GitLab 中使用 OpenAPI 文件(为我的文件运行 UI),但是当我使用从 Swagger UI 尝试/执行功能(向外部 API 发送请求)时,我得到一个内容安全隐私错误。
\n我的 OpenAPI 可在 Swagger 在线编辑器和 Gitlab don\xe2\x80\x99t 中运行。我认为我需要设置这个外部 URL,但我不知道在哪里设置。也许我的 OpenAPI 代码中有什么东西?或者 GitLab 中的设置?
\n错误:
\n\n我正在团队中开发一个新项目,我们正在遵循 API 优先方法来实现 API。我们使用openapi-generator-maven-pluginOpenAPI 3.0.3 格式的 yml 文件生成 API。为了生成 swagger 文件,我们使用 springfox 2.9.2。我面临的问题是当我尝试为请求增加安全性时。
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
security:
- bearerAuth: [ ]
Run Code Online (Sandbox Code Playgroud)
该Authorize按钮不会出现在 swagger 页面中,仅出现请求附近的锁,但它不会执行任何操作(见下图)。
我观察到,如果我打开/v2/api-docsswagger json 不包含安全定义部分。
我设法添加安全性的唯一方法是通过 Docket 对象中的代码添加安全部分,如下所示:
new Docket(DocumentationType.SWAGGER_2)
.securityContexts(Collections.singletonList(securityContext()))
.securitySchemes(Collections.singletonList(bearerJwtKey()))
.select()
.apis(RequestHandlerSelectors.basePackage("com.example"))
.paths(PathSelectors.any())
.build();
Run Code Online (Sandbox Code Playgroud)
这是为 Swagger UI 添加安全性的唯一方法还是我遗漏了什么?
我正在使用 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
annotations ×1
azure ×1
c# ×1
express ×1
gitlab ×1
javalin ×1
jmeter ×1
json ×1
jsonschema ×1
kotlin ×1
node.js ×1
python ×1
rest ×1
spring-boot ×1
swagger-ui ×1
typescript ×1