Closed
Description
Q | A |
---|---|
Bug or feature request? | Bug |
Which Swagger/OpenAPI version? | 2.0 |
Which Swagger-Editor version? | 3.1.7+ |
How did you install Swagger-Editor? | editor.swagger.io |
Which broswer & version? | Chrome 60.0.3112.113 |
Which operating system? | macOS Sierra 10.12.6 |
Demonstration API definition
swagger: "2.0"
info:
description: "allOf issue demonstration"
version: "1.0.0"
title: "Swagger allOf regression"
host: "example.com"
schemes:
- "http"
paths:
/rides:
post:
tags:
- "rides"
summary: "Add a new ride"
description: ""
operationId: "addRide"
parameters:
- in: "body"
name: "body"
description: "Ride object"
required: true
schema:
allOf:
- $ref: "#/definitions/Ride"
responses:
405:
description: "Invalid input"
definitions:
Ride:
type: "object"
required:
- "from"
- "to"
properties:
id:
type: "integer"
format: "int64"
from:
type: "string"
example: "London"
to:
type: "string"
example: "Manchester"
Configuration (browser query string, constructor, config.yaml)
N / A
Expected Behavior
- Click on "Generate Client"
- Select a target language
- Documentation is generated and downloaded
Current Behavior
- Click on "Generate Client"
- Select a target language
- Nothing happens
Browser's development console error:
POST https://generator.swagger.io/api/gen/clients/html2 400 (Bad Request)
swagger-editor-standalone-preset.js:1 Uncaught (in promise) Error: Bad Request
at swagger-editor-standalone-preset.js:1
at <anonymous>
(anonymous) @ swagger-editor-standalone-preset.js:1
Promise rejected (async)
r.downloadGeneratedFile @ swagger-editor-standalone-preset.js:1
n @ swagger-editor-bundle.js:103
s @ swagger-editor-bundle.js:103
a @ swagger-editor-bundle.js:103
f @ swagger-editor-bundle.js:103
m @ swagger-editor-bundle.js:103
r @ swagger-editor-bundle.js:103
processEventQueue @ swagger-editor-bundle.js:103
n @ swagger-editor-bundle.js:117
handleTopLevel @ swagger-editor-bundle.js:117
o @ swagger-editor-bundle.js:119
perform @ swagger-editor-bundle.js:103
batchedUpdates @ swagger-editor-bundle.js:119
o @ swagger-editor-bundle.js:103
dispatchEvent @ swagger-editor-bundle.js:119
Response:
{"code":1,"type":"error","message":"Unable to build target: Could not process operation:\n Tag: rides\n Operation: addRide\n Resource: post /rides\n Definitions: {Ride=io.swagger.models.ModelImpl@c32f7a5d}\n Exception: null"}
Possible Solution
Something changed between version 3.1.5 and 3.1.6
Lines generating the issue are:
schema:
allOf:
- $ref: '#/definitions/Ride'
Of course, if I remove allOf:
such as:
schema:
$ref: '#/definitions/Ride'
documentation will be generated successfully
Context
I'm using an endpoint which could create multiple objects. In the simplified example above, let's imagine that I need an extra boolean attribute "round_trip", which creates two rides, inverting from
and to
fields.
schema:
allOf:
- $ref: '#/definitions/Ride'
- type: object
properties:
round_trip:
description: Create another ride with inverted `from` and `to` fields
type: boolean
default: false
example: false
Metadata
Metadata
Assignees
Labels
No labels