swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[BUG]missing swagger input or config

Open chaoshen1024 opened this issue 7 years ago • 27 comments

Description

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

Swagger-codegen version

3.0.0-SNAPSHOT

chaoshen1024 avatar Sep 06 '17 08:09 chaoshen1024

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

dariota avatar Sep 16 '17 12:09 dariota

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

dariota avatar Sep 18 '17 20:09 dariota

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

chaoshen1024 avatar Sep 19 '17 02:09 chaoshen1024

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.

dariota avatar Sep 23 '17 16:09 dariota

thanks

chaoshen1024 avatar Sep 26 '17 13:09 chaoshen1024

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

dancrumb avatar Oct 21 '17 16:10 dancrumb

Still broken as of 1/12/2018

AaronHarris avatar Jan 12 '18 20:01 AaronHarris

any news on this?

catadincu avatar Feb 28 '18 18:02 catadincu

Is this still broken?

jayaj1911 avatar Jan 28 '19 12:01 jayaj1911

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?

ljnocca avatar Feb 15 '19 15:02 ljnocca

issue still present

riteshkapse avatar Mar 01 '19 11:03 riteshkapse

yeah I just hit this :/

Ryan-Palmer avatar Mar 07 '19 14:03 Ryan-Palmer

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

jayaj1911 avatar Mar 08 '19 05:03 jayaj1911

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)

Ryan-Palmer avatar Mar 08 '19 09:03 Ryan-Palmer

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!)

suhasIVT avatar Mar 22 '19 13:03 suhasIVT

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

riteshkapse avatar Mar 22 '19 13:03 riteshkapse

hello, i have the same error with https://developer.atlassian.com/cloud/jira/platform/swagger-v3.v3.json

kireyzambon avatar Apr 08 '19 12:04 kireyzambon

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.

RugerSR9 avatar Jun 12 '19 20:06 RugerSR9

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

daniilmatafonov avatar Aug 16 '19 09:08 daniilmatafonov

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

samheihey avatar Aug 29 '19 08:08 samheihey

Any update on this?

brianpooe avatar Mar 10 '20 09:03 brianpooe

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.

magex9 avatar Mar 31 '20 10:03 magex9

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

beRoberto avatar Apr 15 '20 19:04 beRoberto

Check using single space and not tab!

salvatorevitale-github avatar Jan 29 '21 00:01 salvatorevitale-github

I believe the issue here is that we are using a very old codegen version.

It turns out the latest published docker image is 2.4.29 which doesn't support OpenAPI v3.

Would the Swagger team be so kind to publish a fresh docker image for us, please? It would be really nice if we could use a dockerized version of the codegen.

Thank you!

CC @wing328

Kolyunya avatar Jan 01 '23 22:01 Kolyunya

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.

openapi-generator-cli has issues too

docker run --rm -v C:\dev\client\projects:/local openapitools/openapi-generator-cli generate -i \ /local/temp/swagger.json\ -l typescript-angular -o /local/api-swagger-client/src

Error

docker: Error response from daemon: error creating overlay mount to /var/lib/docker/overlay2/b5f75883216e4f35f2f9c1e0b1022216f234728ca9ad20eb152856c710f973cc-init/merged: too many levels of symbolic links.
See 'docker run --help'.

DanTurco avatar Oct 26 '23 14:10 DanTurco

I get the same error as well

docker run --rm -v C:\dev\client\projects:/local swaggerapi/swagger-codegen-cli generate -i \ /local/temp/swagger.json\ -l typescript-angular -o /local/api-swagger-client/src [main] INFO io.swagger.parser.Swagger20Parser - reading from /local/temp/swagger.json [main] INFO io.swagger.parser.Swagger20Parser - reading from /local/temp/swagger.json [main] INFO io.swagger.codegen.ignore.CodegenIgnoreProcessor - No .swagger-codegen-ignore file found. Exception in thread "main" java.lang.RuntimeException: missing swagger input or config! at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:766) at io.swagger.codegen.cmd.Generate.run(Generate.java:307) at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)

DanTurco avatar Oct 26 '23 14:10 DanTurco