天道酬勤,学无止境

swagger-editor

How Can I add basic auth in swagger 3.0 automatically with out the user to type in at authorize button?

I am using swagger 3.0 and have multiple endpoints in swagger docs. I want user not to type in credentials at authorize button every time. Is there any way I can include authentication in index.html or in my yaml files to automatically authorize the user. Thanks.

2021-11-26 12:57:21    分类:问答    swagger   swagger-ui   swagger-editor   openapi

如何为`map` 对象中的属性名称编写 OpenAPI 3 (Swagger) 规范?(How to write OpenAPI 3 (Swagger) specification for property name in `map` object?)

问题 我试图描述的 API 有一个结构,其中根对象可以包含任意数量的子对象(属性本身就是对象)。 “键”或根对象中的属性是子对象的唯一标识符,值是子对象的其余数据。 { "child1": { ... bunch of stuff ... }, "child2": { ... bunch of stuff ... }, ... } 这可以类似地建模为一个数组,例如: [ { "id": "child1", ... bunch of stuff ... }, { "id": "child2", ... bunch of stuff ... }, ... ] 但这既使结构上不太清楚识别属性是什么,并使子代 ID 之间的唯一性隐式而非显式,因此我们想要使用对象或映射。 我已经看过 Model with Map/Dictionary Properties 的 Swagger 文档,但这并不完全适合我的用例。 写一些类似的东西: "Parent": { "additionalProperties": { "$ref": "#/components/schemas/Child", } 产生这样的东西: 这充分传达了属性中值的描述性,但我如何记录对象中“键”的限制? 理想情况下,我想说“这不仅仅是任意字符串,而是与孩子对应的 ID”。 这是否以任何方式支持? 回答1 你的例子是正确的。

2021-11-23 03:31:02    分类:技术分享    swagger   swagger-editor   openapi

Swagger Editor offline installation

Our company is using swagger to document their API's, currently a couple of developers are using the online swagger editor on their PC's. I want to move this piece of the design process into our standard development environment, which is in a walled garden without internet access. How do I go about installing npm and the swagger editor in an offline environment? There are options to use either RHEL or Windows machines, although Windows is preferable as developers have local admin rights

2021-11-22 06:27:25    分类:问答    swagger-editor

nullable fields in swagger on node.js

I've spent a bunch of time trying to find a solution for creating swagger docs in Node.JS. The main library is swagger-node, in which you create a swagger yaml file and then add your controllers to it. It automatically provides swagger ui docs in your app and does validation on the request & response against the models you specify in your yaml. This is neat, however I have a requirement that some fields I want to explicitly be able to return or accept null as a value, for instance: { id: 123, description: "string", date_sent: null } I don't want to delete the date_sent key, I want to

2021-11-22 04:39:36    分类:问答    node.js   swagger   swagger-ui   swagger-editor

Swagger Editor shows "Failed to fetch" error

I'm new to Swagger and using Swagger Editor running locally on my desktop to test an API. I'm not responsible for server configuration, and have no access to make changes. I have my security definitions set up and my authorization working. Now I'm trying to set up my first path schema, but when I execute it, I get an error message that says "TypeError: Failed to fetch" and the Response Headers field is empty. However, when I copy the Curl request provided by Swagger Editor and run it in GitBash, it returns the value I expect. So I know that Swagger Editor has created a working request. I know

2021-11-20 16:34:45    分类:问答    swagger-editor

How to write OpenAPI 3 (Swagger) specification for property name in `map` object?

The API I'm trying to describe has a structure where the root object can contain an arbitrary number of child objects (properties that are themselves objects). The "key", or property in the root object, is the unique identifier of the child object, and the value is the rest of the child object's data. { "child1": { ... bunch of stuff ... }, "child2": { ... bunch of stuff ... }, ... } This could similarly be modeled as an array, e.g.: [ { "id": "child1", ... bunch of stuff ... }, { "id": "child2", ... bunch of stuff ... }, ... ] but this both makes it structurally less clear what the

2021-11-15 06:50:17    分类:问答    swagger   swagger-editor   openapi

Swagger 编辑器显示路径参数的“架构错误:不应具有附加属性”错误(Swagger Editor shows the “Schema error: should NOT have additional properties” error for a path parameter)

问题 我正在创建一个 OpenAPI (Swagger) 定义并在 http://editor.swagger.io 中检查其有效性。 出于某种原因,Swagger 编辑器显示此错误: Schema error at paths['/some-endpoint/{id}/name-and-address'].get.parameters[0] should NOT have additional properties additionalProperty: type, allowEmptyValue, enum, name, in, description, required Jump to line 142 下面是我的 YAML 文件: paths: '/some-endpoint/{id}/name-and-address': get: tags: - InvolvedParty summary: Retrieve basic information about... operationId: getNameAndAddressUsingGET produces: - '*/*' parameters: - name: id in: path description: The unique identification required: true type: string

2021-11-15 04:27:50    分类:技术分享    swagger   swagger-2.0   swagger-editor

Swagger Editor shows the “Schema error: should NOT have additional properties” error for a path parameter

I am creating an OpenAPI (Swagger) definition and checking its validity in http://editor.swagger.io. For some reason, Swagger Editor shows this error: Schema error at paths['/some-endpoint/{id}/name-and-address'].get.parameters[0] should NOT have additional properties additionalProperty: type, allowEmptyValue, enum, name, in, description, required Jump to line 142 Below is my YAML file: paths: '/some-endpoint/{id}/name-and-address': get: tags: - InvolvedParty summary: Retrieve basic information about... operationId: getNameAndAddressUsingGET produces: - '*/*' parameters: - name: id in: path

2021-11-10 22:31:52    分类:问答    swagger   swagger-2.0   swagger-editor

如何在 OpenAPI 3.0 中定义作为原始数据类型的可重用主体参数?(How to define a reusable body parameter that is a primitive data type in OpenAPI 3.0?)

问题 我正在创建一个 API 的 OpenAPI 3.0 规范/描述,其中许多请求主体包含一些相同的参数,这些参数是原始数据类型,如字符串或整数。 例如: imei: type: integer format: int64 description: 4G hardware device identifier 我想在“组件”对象中只定义一次这些参数,然后使用 $ref 将它们包含在需要的地方,而不是在十几个不同的请求正文中定义相同的参数。 我一直无法找到一种方法来做到这一点。 “参数”对象中定义的参数不能在请求正文中使用。 无赖。 我认为这在 2.0 中是允许的。 我可以在“模式”对象中定义这些参数,但 Swagger Editor 然后在“模型”下显示它们。 将原始数据类型的参数称为模型有点牵强。 这些是模型中使用的参数,而不是模型本身。 我已经广泛搜索了 SO 和网络,但没有找到解决这个特定问题。 也许答案是“它无法完成”,但这似乎是 OpenAPI 技术委员会的疏忽。

2021-10-24 00:59:29    分类:技术分享    openapi   swagger-editor

如何在不破坏 Codegen 的情况下在 Swagger 中添加几个示例来响应?(How to add several examples to response in Swagger without breaking Codegen?)

问题 我一直在尝试根据官方文档向我的 Swagger API 添加示例(请参阅请求和响应正文示例的最后一个代码块),但它似乎没有按预期工作。 考虑以下最小示例: swagger: "2.0" info: description: Desc version: "1" title: Title paths: /stuff: post: produces: - application/json responses: 201: description: It worked content: application/json: schema: $ref: "#/definitions/StatusMessage" examples: Success without message: value: code: "00000" Success with message: value: code: "00000" message: "All right" definitions: StatusMessage: type: object description: Response with code and optional message properties: code: type: string message: type: string required: - code 我想提供示例响应

2021-10-23 22:03:53    分类:技术分享    spring-boot   swagger-ui   swagger-2.0   swagger-codegen   swagger-editor