How to set Schemes default value to HTTPS
In the browser console I receive this when trying to identify my Swagger UI version: JSON.stringify(versions) '{"swaggerUI":{"version":"5.17.14","gitRevision":"g8aa52920","gitDirty":true,"buildTimestamp":"Tue, 28 May 2024 05:23:41 GMT"}}' Looking in the UI it looks like a 3.x version My question is as follows: In the Swagger UI there is a field named Schemes. This field has the values HTTP and HTTPS but always defaults to HTTP and we manually have to set it to HTTPS before starting to use the tool. How do I for the field Schemes permanently set the default value to be HTTPS? We have a load balancer between the computer clients and the web server. The load balancer has the certificate and perform https offloading. The communication between the load balancer and the web servers is done with http. Example how I want it to be can be seen at this web pagehttps://petstore.swagger.io Where you can see the field Schemes is set to HTTPS as default when accessing the page. I've searched this forum and other sources trying to find the answer to this question without any luck. Any idea is much appreciated.Recursive schemas and contributions to swagger-ui
Hello, I'm working on a project that uses a spec that is recursive, and due an old issue (from 2017 - see note 1), swagger-ui can't render it. It can easily reproduced (as in note 3) I would like to know: I'm the only one using recursive schemas? There is some kind of workaround? I would like to work on a fix to it. But a few days ago I wrote a PR (note 2) to fix another issue, and it seems to be ignored by the main contributors. So before write another PR, I would like to ask: how to not be ignored by the community? 1. https://github.com/swagger-api/swagger-ui/issues/3325 2. https://github.com/swagger-api/swagger-ui/pull/8400 3. Enter https://editor-next.swagger.io/ and paste this schema openapi: 3.0.3 info: {title: "recur", version: "1.0.0"} paths: /pet: put: responses: default: description: Successful operation content: application/json: schema: $ref: '#/components/schemas/Pet' components: schemas: Pet: type: object properties: name: {type: number} myself: {$ref: "#/components/schemas/Pet"}1.5KViews0likes2CommentsRegarding swagger is not working in nodejs as per the swagger document.
Hi there, I tried to setup swagger on nodejs as per the document par it is not working and present wrong data of swagger UI see the below attached screenshot. So just wanted to know how to setup swagger in nodejs so that all my apis display in one place. I tried lot of solutions on different different websites but same issue appeared. So kindly guide how to do that so that swagger is running properly. Reference site that I tried below: https://swagger.io/docs/open-source-tools/swagger-codegen/#:~:text=The%20Swagger%20Codegen%20is%20an,can%20be%20found%20in%20GitHub. https://levelup.gitconnected.com/how-to-add-swagger-ui-to-existing-node-js-and-express-js-project-2c8bad9364ce https://medium.com/bb-tutorials-and-thoughts/how-to-add-swagger-to-nodejs-rest-api-7a542cfdc5e1 https://plainenglish.io/blog/how-to-implement-and-use-swagger-in-nodejs-d0b95e765245 https://dev.to/kabartolo/how-to-document-an-express-api-with-swagger-ui-and-jsdoc-50do https://itnext.io/setting-up-swagger-in-a-node-js-application-d3c4d7aa56d4 https://github.com/Surnet/swagger-jsdoc/blob/master/README.md Looking forward to hearing from you. Thanks! Swagger.json: { "swagger": "2.0", "info": { "version": "1.0.0", "title": "My User Project CRUD", "description": "My User Project Application API", "license": { "name": "MIT", "url": "https://opensource.org/licenses/MIT" } }, "host": "localhost:3000", "basePath": "/", "tags": [ { "name": "Users", "description": "API for users in the system" } ], "schemes": ["http"], "consumes": ["application/json"], "produces": ["application/json"] } Server.js: import swaggerUi from 'swagger-ui-express'; import swaggerDocument from './swagger.json'; app.use( '/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument) ); app.listen(port, () => { console.log(`Server running at ${process.env.SERVER_URL}`); });swagger 3.0 request body is getting reset to default value while I collapse the API request.
swagger 3.0 request body is getting reset to default value when I collapse the API request. I want if any of the field in request body gets updated it should persist the value even after collapsing the API request. request body: { "id": "string", "seqno": "string" } modified request body: { "id": "1000", "seqno": "12" } Now If I collapse the API in swagger UI, I see the entered data lost and now request body is showing default value: { "id": "string", "seqno": "string" }How can we reference helm values in a static swagger file
i have tried components: securitySchemes: oauth: type: oauth2 description: This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth) flows: authorizationCode: authorizationUrl: ${AUTHORIZATION_URL} tokenUrl: ${TOKEN_URL} scopes: {} and also components: securitySchemes: oauth: type: oauth2 description: This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth) flows: authorizationCode: authorizationUrl: {{env "AUTHORIZATION_URL" } tokenUrl: {{ env "TOKEN_URL" }} scopes: {} I have container for swagger, both above doesnt seem to work any ideas would be helpful ThanksRepresenting Xml array of strings (or primatives)
It's clear from the documentation that if you have an Array with objects you can represent it in the right way (e.g. <Addresses><Address></Address></Addresses>) by adding:xml:wrapped : true and providing a name to the item scheme. However, what if the array is of primitive type or string? I'm trying to create a SchemaFilter to easily provide the right examples in Swagger when selecting the xml type. I am getting the information for the formatting from xml attributes. For arrays that have objects this is doable as I can easily set the schema name of the object. However, there is no schema for a string so I cannot set the name. The closest I can get is <Addresses><Addresses> </Addresses></Addresses>. Is there a way to work around the setting of the name but still have the same effect of having a different wrapped name?Swagger UI not filling multiple route params
I am implementing Swagger into an ExpressJs API application. In the controller files, we are using nested folders and "const router = require('express').Router({ mergeParams: true });" to inherit path variables from parent folders. When I run my swagger implementation, anything deeper than the parent folder will not dynamically put in the route variables provided from the swagger UI. Example: I will put in the variables "mineID' and "incidentId" from the text boxes in swagger ui, then this is the exact curl request sent in swagger, where you can see that the second route parameter has not been filled: curl -X 'GET' \ 'http://localhost:4900/v2/mines/56677888/incidents/{incidentId}/current' \ Above, you can see how the request did not correctly fill the second param it was given in the Swagger UI. I can confirm that the definition for these variables is correct and the route param name and path name in my definition match correctly. Also, this controller is working successfully in production and has been tested thouroughly. In my implementation of swagger, I am using jsdocs in a seperate file, but in the same folder as the controller code. How might I get these variables to populate correctly? It is working elsewhere in the application and I only need solutions for the swagger implementation, the API code is tested and working fine on its own Any help would be appreciated, this is causing me more trouble than I'd like. Thanks.Multiple path params not working
Hi Folks, Recently I have encountered an issue where I have two path parameters for an api endpoint where both are mandatory, but when we execute the api via swagger and pass the value for them, for 1st param its fetching fine but for 2nd one its returning the name of the paramater. Below are the details. For Example: I have passed 2 values for 2 fields named as budget_name and partition_name as budget1 and partition1 but when I logged(print) them, I got budget1 [which is correct] and {partition1} [not correct its treating field name as value].