swagger-api / swagger-api/swagger-codegen

Generate Client javascript is not working in the online version (https://editor.swagger.io)

Open
#8,017 0 comments 3 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 @cc616 on April 13, 2018 3:47

Q A
Bug or feature request? bug
Which Swagger/OpenAPI version? 2.0
Which Swagger-Editor version? online
How did you install Swagger-Editor? online
Which browser & version? Chrome 65.0.3325.181
Which operating system? OSX 10.11.6 (15G31)
Demonstration API definition
---
swagger: "2.0"
info:
  description: "API description in Markdown."
  version: "1.0.0"
  title: "Sample API"
host: "localhost:8000"
basePath: "/v1"
schemes:
- "http"
produces:
- "application/json"
paths:
  /login:
    post:
      tags:
      - "Auth"
      summary: "用户登录"
      description: "用户登录"
      operationId: "login"
      parameters:
      - in: "body"
        name: "user"
        description: "用户名和密码"
        required: false
        schema:
          $ref: "#/definitions/user"
      responses:
        200:
          description: "successful"
        400:
          description: "Bad request"
        404:
          description: "Not found"
      x-swagger-router-controller: "Auth"
definitions:
  user:
    type: "object"
    required:
    - "password"
    - "username"
    properties:
      username:
        type: "string"
        description: "用户名"
      password:
        type: "string"
        description: "密码"

Configuration (browser query string, constructor, config.yaml)
import api from 'lcc-person'

const test = () => {
  console.log(api)
}
Expected Behavior

start project, console:Module not found: Can't resolve 'ApiClient' in '/Users/cc/cc/personal-web/node_modules/lcc-person/src'

Current Behavior

image

Possible Solution
Context

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

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 by reproducing the issue in the online Swagger Editor using the supplied Swagger 2.0 definition and the reported Chrome environment. Trace the generated JavaScript client around the missing ApiClient module and compare the generated imports with the available files. Done means the generated client can be imported and used without the module-resolution error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.