question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Put swagger version at the top of generated spec so IDE recognises swagger file

See original GitHub issue

IntelliJ does not recognise the generated spec file as a swagger file, and just opens it as a YAML/JSON file.

Sorting

  • I’m submitting a …

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn’t already been submit

Expected Behavior

swagger: '2.0'
basePath: ...
...

Current Behavior

swagger: '2.0' is near the bottom of the generated spec file

...
paths: ...
produces: ...
swagger: '2.0'

Possible Solution

specGenerator2.ts

let spec: Swagger.Spec2 = {
      swagger: '2.0',
      basePath: normalisePath(this.config.basePath as string, '/', undefined, false),
      consumes: ['application/json'],
      definitions: this.buildDefinitions(),
      info: {
        title: '',
      },
      paths: this.buildPaths(),
      produces: ['application/json'],
    };

Steps to Reproduce

Context (Environment)

Version of the library: 3.7.0 Version of NodeJS: v15.11.0

  • Confirm you were using yarn not npm: [x]

Detailed Description

Breaking change?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
WoHcommented, May 21, 2021

Can you link the Jetbrains issue, so I can keep track of the progress? If they don’t decide to fix this, we should consider moving up the swagger/openapi key on our side to avoid the inconvenience, at least for tsoa users. However, I would prefer if Jetbrains decided to fix the detection on their end for everyone.

0reactions
dPetruniakcommented, Sep 24, 2021

The same problem with Cortex. It expects openapi: 3.0.0 on the first row image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detecting your Swagger UI version
The first step would be to detect which major version you currently use, as the method of detecting the version has changed.
Read more >
The files and directory structures output into generated ...
I've managed to get it to output only the Java sources to /target/generated-sources/swagger/. It compiles successfully and my IDE recognizes the ...
Read more >
Using OpenAPI and Swagger UI - Quarkus
Swagger UI is a great tool permitting to visualize and interact with your APIs. The UI is automatically generated from your OpenAPI specification....
Read more >
OpenAPI | IntelliJ IDEA Documentation - JetBrains
Swagger is a set of tools based on this specification for writing, documenting, and consuming REST APIs. For more information, see Swagger ......
Read more >
Use Swagger to document and define RESTful APIs
Several Swagger editing tools help you to create API documents easily and ensure that they conform to the OpenAPI spec. With Swagger Editor,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found