swagger-api / swagger-api/swagger-codegen

Running OAS 3.0 in Editor creates error when generating code (server or client)

Open
#8,795 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

From @peterwilli on October 2, 2018 21:0

Q&A (please complete the following information)
  • OS: Linux
  • Browser: Chromium
  • Version: 69.0.3497.81
  • Method of installation: Online editor
  • Swagger-Editor version: No version number found in the Online Editor
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Go to https://editor.swagger.io or host your own (I had this issue with both)

Example Swagger/OpenAPI definition:

openapi: "3.0.1"
info:
  version: 0.1.0
  title: Test API
  description: Test API
servers:
  - url: "http://localhost:7000"
  
paths:
  /user:
    post:
      summary: Registers new user
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                username:
                  type: string
                password:
                  type: string
                email:
                  type: string
              required:
                - username
                - password
                - email
              example:
                username: peterwilli
      responses:
        '200':
          description: |-
            200 response
          content:
            text/plain:
              examples: 
                ok:
                  value: "ok"
Describe the bug you're encountering
To reproduce...

Steps to reproduce the behavior:

  1. Paste example YAML in editor.
  2. In the top bar, try to generate any client or server.
  3. Nothing will happen.
  4. If you go to the console and the networking tab, you'll see the error there.
Expected behavior

A download with the client or server would be presented.

Screenshots

swagger editor - chromium_042

Additional context or thoughts

The weird thing is that this OAS code does work fine: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml

Copied from original issue: swagger-api/swagger-editor#1894

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the example OpenAPI YAML in the issue, load it in the online editor, and inspect the browser console and networking tab while attempting client or server generation. Trace the generation request from the editor entry point; done means a client or server download is presented for this definition, as it is for the linked petstore example.

Written by the indexing model from the issue text.

Assessment

Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.