Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]missing swagger input or config #6442

Open
chaoshen1024 opened this issue Sep 6, 2017 · 28 comments
Open

[BUG]missing swagger input or config #6442

chaoshen1024 opened this issue Sep 6, 2017 · 28 comments

Comments

@chaoshen1024
Copy link

Description

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

Swagger-codegen version

3.0.0-SNAPSHOT

@chaoshen1024 chaoshen1024 changed the title missing swagger input or config [BUG]missing swagger input or config Sep 6, 2017
@dariota
Copy link
Contributor

dariota commented Sep 16, 2017

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

@dariota
Copy link
Contributor

dariota commented Sep 18, 2017

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

@chaoshen1024
Copy link
Author

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

@dariota
Copy link
Contributor

dariota commented Sep 23, 2017

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.

@chaoshen1024
Copy link
Author

thanks

@dancrumb
Copy link

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

@AaronHarris
Copy link

Still broken as of 1/12/2018

@catadincu
Copy link

any news on this?

@jayaj1911
Copy link

Is this still broken?

@ljnocca
Copy link

ljnocca commented Feb 15, 2019

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?

@riteshkapse
Copy link

riteshkapse commented Mar 1, 2019

issue still present

@Ryan-Palmer
Copy link

yeah I just hit this :/

@jayaj1911
Copy link

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

@Ryan-Palmer
Copy link

Ryan-Palmer commented Mar 8, 2019

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 #9241)

@suhasIVT
Copy link

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

@riteshkapse
Copy link

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

@kireyzambon
Copy link

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

@RugerSR9
Copy link

RugerSR9 commented Jun 12, 2019

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.

@daniilmatafonov
Copy link

daniilmatafonov commented Aug 16, 2019

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

@samheihey
Copy link

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

@brianpooe
Copy link

Any update on this?

@magex9
Copy link

magex9 commented Mar 31, 2020

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.

@beRoberto
Copy link

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

@salvatorevitale-github
Copy link

Check using single space and not tab!

@Kolyunya
Copy link

Kolyunya commented Jan 1, 2023

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

@DanTurco
Copy link

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
Copy link

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)

@alteredtech
Copy link

8 years later and still not fixed

docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate \
    -i /local/openapi.json \
    -l python-flask \
    -o /local/PetStoreServer
[main] INFO io.swagger.parser.Swagger20Parser - reading from /local/openapi.json
[main] INFO io.swagger.parser.Swagger20Parser - reading from /local/openapi.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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests