Swagger on local works fine and send a correct Authorization token
Deploying on Dev environment with same configuration cause this.
Authorization: Bearer [object Object]
its converting JWT token to [object Object] it was working perfectly a couple of days ago with the same modules
"swagger-ui-express": "^4.3.0",
"#nestjs/swagger": "^5.2.0"
This was a bug introduced in Swagger UI v. 4.7.0. It was fixed in Swagger UI v. 4.8.1.
Update your packages to the versions that include Swagger UI v. 4.8.1.
Related
I have a simple GET API. When I click "Try it out" and then "Execute" in Swagger UI, I can see the request reaching the server and getting processed successfully with HTTP status code 200 - ascertained by looking into the server logs.
I would like to see the response body in Swagger UI. What addition or change needs to be done to the OpenAPI YAML spec? I'm using OpenAPI 3.0.3.
By enabling CORS in my flask app, I have managed to overcome the issue ...
From shell prompt ...
pip install -U flask-cors
Inside app.py ...
...
from flask_cors import CORS
...
app = Flask(__name__)
CORS(app)
...
I am using swagger to show my open API YAML file, it suddenly gives me "response status is 404 /openapi.yaml" when I run the spring boot application.
Note : I can open the /api-docs/ in swagger and it shows the apis, also when I hit the swagger config URL (http://localhost:8080/api-docs/swagger-config), it gives me the below response, which include the openapi.yaml file
{"configUrl":"/api-docs/swagger-config","oauth2RedirectUrl":"http://localhost:8080/swagger-ui/oauth2-redirect.html","url":"/openapi.yaml","validatorUrl":""}
The problem happened only in my machine, other colleagues' machines work fine with the same codebase.
Deps:
org.springdoc:springdoc-openapi-ui:1.6.11
org.springdoc:springdoc-openapi-javadoc:1.6.11
org.springdoc:springdoc-openapi-data-rest:1.6.11
org.springdoc:springdoc-openapi-security:1.6.11
io.swagger:swagger-annotations:1.6.6
org.openapitools:jackson-databind-nullable:0.2.2
io.swagger.parser.v3:swagger-parser:2.0.32
org.openapi.generator version "5.4.0" // open API generator plugin
My api is running net core 3.0 with Swashbuckle.AspNetCore 5.0.0-rc5
When I run autorest on my generated swagger.json file I get:
swagger.json is not a valid OpenAPI 2.0 definition (expected 'swagger: 2.0')
My swagger.json file does indeed say "openapi": "3.0.1".
It used to be v2.0 but since I upgraded to net core 3.0 I had to upgrade Swashbuckle which now creates the json file with v3.0.1
I ran "choco install autorest" so I should be running the latest version
If autorest doesn't support openapi3.0 there must still surely be a way to generate an openapi2.0 json file?
Followed this thread, auto rest doesn’t support latest open api yet but there are workarounds
https://github.com/Azure/autorest/issues/2680
You can do this:
app.UseSwagger(o => o.SerializeAsV2 = true);
looks like official swagger for openapi specification V3 support is near release https://blog.readme.io/an-example-filled-guide-to-swagger-3-2/, and the swagger-codegen has 3.0.0 support developed and passing some level of testing https://github.com/swagger-api/swagger-codegen on the 3.0.0 branch
I have a swagger spec (generated from my existing 2.0 spec via https://github.com/mermade/swagger2openapi, output looks good)
Is there an easy way to run the swagger-codegen without having to package the jar myself?
this is the single result i found: https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen-cli/3.0.0-SNAPSHOT/ but running that seems to be broken (from the output, possibly actually running 2.0 not 3.0.0?):
[main] INFO io.swagger.parser.Swagger20Parser - reading from /input/myspec.openapi3.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:685)
at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
It looks like the swagger-codegen repo has a somewhat supported way to run a docker container after you build; I'm just hoping/guessing there is a supported way to do this without needing to compile locally, as I need to set this up in several places.
OpenAPI Generator (found by top contributors of Swagger Codegen) supports both OpenAPI specification v2 and v3.
You can use the docker images, Java JAR (SNAPSHOT), Brew or npm to give it a try.
For more information about OpenAPI Generator, please refer to the project's README
If you need any help, please open an issue and we'll look into it.
UPDATE: 1st stable version 3.0.0 has been released: https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.0
Swagger-codegen 3.0.0 snapshots now include a limited number of targets for code generation from OpenAPI 3.0 definitions. https://github.com/swagger-api/swagger-codegen/issues/6598#issuecomment-333428808
There is an alternative experimental implementation of the codegen engine, using the original swagger-codegen 2.x templates, written in Node.js: https://github.com/mermade/openapi-codegen - if your language is not yet supported, a config file just needs to be created for it mapping the template files to outputs.
I need to create swagger codegen client for java, javascript pointing to swagger yaml pusblished on https.
When tried below command got SSLHandshakeError.
"swagger-codegen generate -i https://localhost:443/api/swagger.yaml -l java -o java-api/."
Also when swagger codegen generates client will it have SSL Mutual TLS code for https swagger spec url?
Please help.
Please add -D io.swagger.parser.util.RemoteUrl.trustAll=true when generating the code.
Ref: https://github.com/swagger-api/swagger-codegen/wiki/FAQ#is-there-a-way-to-disable-certificate-verification
UPDATE: On May 2018, about 50 top contributors and template creators of Swagger Codegen decided to fork Swagger Codegen to maintain a community-driven version called OpenAPI Generator. Please refer to the Q&A for more information.
the above answer didn't work for me. if you are facing the same problem as I just use the bellow structure
( "swagger:generate": "SET JAVA_OPTS=-Dio.swagger.parser.util.RemoteUrl.trustAll=true -Dio.swagger.v3.parser.util.RemoteUrl.trustAll=true && openapi-generator generate -i https://xxxxxx/swagger/1.0/swagger.json -g typescript-angular -o ./src/code-gen"
)
that's how I solved it