swagger-api / swagger-api/swagger-codegen
[HTML] OAS3.0 code without components block throws 500
Open
@HugoMario is already working on this.
Since May 22, 2018.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
If your OAS3.0 YAML definition doesn't have a components block, the editor doesn't show any errors - but clicking generate client throws an HTTP 500 error in the Chrome Dev Console.
Swagger-codegen version
Whatever is running at generator3.swagger.io/v2/generate.json
Swagger declaration file content or url
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
default:
description: unexpected error
content:
application/json:
schema:
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
default:
description: unexpected error
content:
application/json:
schema:
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
# components:
# schemas:
# Pet:
# required:
# - id
# - name
# properties:
# id:
# type: integer
# format: int64
# name:
# type: string
# tag:
# type: string
# Pets:
# type: array
# items:
# $ref: "#/components/schemas/Pet"
# Error:
# required:
# - code
# - message
# properties:
# code:
# type: integer
# format: int32
# message:
# type: string
Command line used for generation
n/a
Steps to reproduce
- Paste above YAML in editor.swagger.io (use HTTP because of this: https://github.com/swagger-api/swagger-editor/issues/1762)
- Click generate client
- Observe 500 error in Chrome Dev Console
Note that the editor shows no errors with components commented out. If you un-comment the components section, it works.
Suggest a fix/enhancement
If the editor doesn't show an error, the generator should work. I'm not sure what is going wrong here to cause this problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.