Swagger 如何为每个HTTP状态代码提供单独的示例?

Swagger 如何为每个HTTP状态代码提供单独的示例?,swagger,openapi,dredd,Swagger,Openapi,Dredd,我在试图指示Dredd发出不同的请求以触发两种不同的场景时遇到了问题:代码201成功,代码400失败 我试图为每个HTTP状态代码设置一个单独的示例,但无法做到这一点。 我可以在requestBody中添加example部分,但随后它将在两个示例中使用-用于成功和失败 openapi: 3.0.2 info: description: Body example per HTTP code illustration version: 1.0.0 title: Profile

我在试图指示Dredd发出不同的请求以触发两种不同的场景时遇到了问题:代码201成功,代码400失败

我试图为每个HTTP状态代码设置一个单独的示例,但无法做到这一点。 我可以在
requestBody
中添加
example
部分,但随后它将在两个示例中使用-用于成功和失败

openapi: 3.0.2
info:  
  description: Body example per HTTP code illustration  
  version: 1.0.0  
  title: Profile 
tags:
  - name: profile
    description: User profiles
paths:  
  /profiles:
    post:     
      tags:        
        - profiles
      summary: Create profile
      operationId: createProfile
      requestBody:        
        description: Create Profile
        content:          
          application/json:            
            schema:              
              $ref: '#/components/schemas/CreateProfile'
        required: true      
      responses:        
        '201':          
          description: Successful operation          
          headers:            
            Location:              
              schema:                
                type: string                
                description: Profile location        
        '400':          
          description: Profile is invalid (missing fields/null values)
          content:            
            application/json:              
              schema:                
                $ref: '#/components/schemas/ProfileCreationError'              
              examples:                
                failing_scenrio:                  
                  summary: An example tailored to work with Dredd                  
                  value:                   
                    name: can't be blank                    
                    email: can't be blank
components:  
  schemas:    
    CreateProfile:      
      type: object      
      required:        
        - name        
        - email        
        - age     
      properties:        
        name:          
          type: string        
        email:          
          type: string        
        age:          
          type: integer          
          format: int32          
          minimum: 0    
    ProfileCreationError:      
      type: object      
      properties:        
        name:          
          type: string        
        email:          
          type: string        
        age:          
          type: integer

我希望能够同时对HTTP代码201和400运行测试。有关如何使用
path
param执行相同操作的示例的额外积分。例如,为
/profiles/{id}
(即200和404)提供已找到和未找到的示例。

OpenAPI 3支持目前(2019年7月,Dredd v11.2.9)处于试验阶段,此特定行为尚未定义。该问题作为一个问题进行跟踪。我建议您订阅这个问题,看看它什么时候被解决或者考虑提供一个解决方案。

< P> OpenAPI 3的支持是当前(2019年7月,DRDD V1.2.9)实验,这个特定的行为仍然是未定义的。该问题作为一个问题进行跟踪。我建议您订阅这个问题,看看它什么时候解决或者考虑提供一个解决方案。