Node.js 没有模式的招摇过市帖子正文
我使用节点招摇过市。很好用。我想在不详细定义模式的情况下发布json正文。例如,下面我不想指定对象属性。有没有办法做到这一点Node.js 没有模式的招摇过市帖子正文,node.js,swagger,swagger-ui,swagger-2.0,Node.js,Swagger,Swagger Ui,Swagger 2.0,我使用节点招摇过市。很好用。我想在不详细定义模式的情况下发布json正文。例如,下面我不想指定对象属性。有没有办法做到这一点 /pets: post: description: Add new parameters: - name: id in: body description: data to post required: true type: object responses: '200': description: A list of pe
/pets:
post:
description: Add new
parameters:
- name: id
in: body
description: data to post
required: true
type: object
responses:
'200':
description: A list of pets
schema:
type : string
它不会呈现textarea来发布json数据。请尝试以下YAML:
---
swagger: '2.0'
info:
version: 0.0.0
title: Simple API
paths:
/:
post:
produces:
- application/json
parameters:
- in: body
name: id
required: true
schema:
"$ref": "#/definitions/inBody"
responses:
201:
description: Added
definitions:
inBody:
type: object
如果您使用的是
swagger-ui-express
和swagger-jsdoc
并且不想使用定义,您可以像这样在端点上直接在YAML中定义
/**
* @swagger
* /pets:
* post:
* description: Add new
* produces:
* - application/json
* parameters:
* - name: id
* description: data to post
* in: body
* required: true
* schema:
* type: object
* responses:
* 201:
* description: Pet created
*/
节点摆动模块也有问题。在未定义架构对象属性的情况下,它不会显示textarea。因此,我将节点招摇与swgger ui一起使用。现在它工作得很好。谢谢Sampadaglad的帮助!