Swagger-codegen: [BUG]missing swagger input or config

Created on 6 Sep 2017  路  23Comments  路  Source: swagger-api/swagger-codegen

Description

io.swagger.parser.Swagger20Parser can not parse "openapi"

Swagger-codegen version

3.0.0-SNAPSHOT

Most helpful comment

any news on this?

All 23 comments

Please provide more information about what exactly you're trying to do, such as the exact command you're running.

Sorry, that yaml's a bit broken. Could you send it again in code formatting?

command

java -jar swagger-codegen-cli-3.0.0-20170904.171256-3.jar generate -l spring -c config.json -i swagger.yaml -o E:\Swagger\demo

config.json

{
  "sortParamsByRequiredFlag": true,
  "ensureUniqueParams": true,
  "allowUnicodeIdentifiers": false,
  "modelPackage": "com.xxx.xxx.api.open.dto",
  "apiPackage": "com.xxx.xxx.api.open.api",
  "invokerPackage": "com.xxx.xxx.api.open.invoker",
  "groupId": "com.xxx.xxx",
  "artifactId": "api",
  "artifactVersion": "0.0.1",
  "artifactUrl": "",
  "artifactDescription": "",
  "scmConnection": "",
  "scmDeveloperConnection": "",
  "scmUrl": "",
  "developerName": "xxxx",
  "developerEmail": "[email protected]",
  "developerOrganization": "xxxx",
  "developerOrganizationUrl": "http://www.xxxx.com",
  "licenseName": "Apache 2.0",
  "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.html",
  "sourceFolder": "src/main/java",
  "localVariablePrefix": "",
  "serializableModel": true,
  "bigDecimalAsString": false,
  "fullJavaUtil": false,
  "hideGenerationTimestamp": true,
  "withXml": false,
  "dateLibrary": "java8",
  "java8": true,
  "title": "xxxx",
  "configPackage": "com.xxx.xxx.api.open.config",
  "basePackage": "com.xxx.xxx.api.open",
  "interfaceOnly": false,
  "delegatePattern": false,
  "singleContentTypes": false,
  "async": false,
  "responseWrapper": "",
  "useTags": false,
  "useBeanValidation": true,
  "implicitHeaders": false,
  "swaggerDocketConfig": true,
  "useOptional": true,
  "library": "spring-boot"
}

swagger.yaml

openapi: 3.0.0
info:
  title: demo
  description: demo
  version:0.0.1
  termsOfService: 'http://www.xxxx.com'
  contact:
    email: [email protected]
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
servers:
  - url: 'http://xxxx.xxxx.com'
    description: The url of xxxx
tags:
  - name: Account
    description: Account Info
paths:
  /account/openAccount:
    post:
      tags:
        - Account
      summary: openAccount
      description: openAccount
      operationId: openAccount
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountInfoDTO'
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResultDTO'
components:
  schemas:
    RequestBaseDTO:
      type: object
      properties:
        systemId:
          type: string
          description: System ID
        requestSeq:
          type: string
          description: Request Sequence
        requestTime:
          type: string
          format: date-time
          description: Request Time
      required:
        - systemId
        - requestSeq
        - requestTime
    AccountInfoDTO:
      allOf:
        - $ref: '#/components/schemas/RequestBaseDTO'
        - type: object
          properties:
            username:
              type: string
              description: username
            sex:
              type: string
              description: sex
    ResultDTO:
      type: object
      properties:
        success:
          type: boolean
          description: Is Success?
        errcode:
          type: string
          description: Error Code
        errmsg:
          type: string
          description: Error Message
        data:
          type: string
          description: accountId

I've tracked the issue to this line in swagger-parser. Correcting this to openapi let the generator complete successfully with the provided example yaml, so if you want a quick fix you could try that.

The feature/3.0.0-rc2 branch there has thoroughly changed the structure of that directory, so I suspect there are changes made/being made which the 3.0.0 swagger-codegen branch isn't yet synchronised with.

thanks

Is there any update on when this fix will be available in a snapshot?

Still broken as of 1/12/2018

any news on this?

Is this still broken?

I'm getting this same error when trying to use Open Api spec 3. However, it works fine with spec 2. Anyone have this issue as well?

issue still present

yeah I just hit this :/

Try using this experimental openapi codegen instead. It is v light and works for me: https://github.com/Mermade/openapi-codegen

I tried downloading Swagger codegen 3.0.5 and that 'worked' with OpenApi 3 pretty much, although for some reason it misses out the names of properties in the model constructors and messes up the path to the projects from my sln file although I think these are probably all c# specific. (mentioned here https://github.com/swagger-api/swagger-codegen/issues/9241)

Has this worked for anyone ? OpenApi Spec 3 does not work with io.swagger swagger-codegen-maven-plugin 2.3.1. - I'm getting this error when trying to use Open Api spec 3. However, it works fine with spec 2.
Error - (**java.lang.RuntimeException: missing swagger input or config!)

Download source and generate swagger-codegen-cli.jar jar locally. This worked for me.

Download source and generate swagger-codegen-cli.jar jar locally. This worked for me.

Tried that and still get the same error:

Exception in thread "main" java.lang.RuntimeException: missing swagger input or config! at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:747) at io.swagger.codegen.cmd.Generate.run(Generate.java:285) at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)

Edit: I ended up using @openapitools/openapi-generator-cli and it worked flawlessly.

I also gettting this error while using swagger-codegen-maven-plugin 2.4.7. Could you please fix this?

I had that error too, but then I realize I made 2 mistakes when setting up the controller:
1) Request Method, I changed the method from Get to Post
2) Setting the correct Http Route

After fixing those 2 errors, and the code is generated

Any update on this?

Im getting this error on 2.4.13 as well..

Exception in thread "main" java.lang.RuntimeException: missing swagger input or config!
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:764)
at io.swagger.codegen.cmd.Generate.run(Generate.java:299)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)

Im using openapi 3.0.0 yaml, but converted it to json, neither work.

By default the master branch supports 2.0. The 3.0 support is on the 3.0.0 branch, you have to change to this branch and build again to get it working.

git clone https://github.com/swagger-api/swagger-codegen.git
cd swagger-codegen
git checkout 3.0.0
# after this build as you please
mvn clean package
Was this page helpful?
0 / 5 - 0 ratings