Put swagger version at the top of generated spec so IDE recognises swagger file
See original GitHub issueIntelliJ 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:
- Created 2 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
The same problem with Cortex. It expects
openapi: 3.0.0
on the first row