Regarding 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}`); });2.9KViews0likes6CommentsNEED HELP WITH A PROJECT | Media type as urlencoded | Optional field
Hello, I need support for a project that i am working on. So, I am generating a swagger doc for RestAPIs and running those in a spring-boot project. Now, with one of the api, media type is application/x-www-form-urlencoded and for the schema, there are couple of optional fields (the service that would be calling my service may pass those fields, or may not). When making a schema, i declare all the required fields and exclude those that are optional, and it reflects in the documentation. But, In Spring-Boot, when I build my swagger code, I optional fields in generated interface is set to required=true. Please help me with this.Swagger Editor (Local) CORS Error
Sorry, a Noobie question... Currently developing an OAS against one of our vendor's REST APIs for ingestion into Salesforce. I've downloaded the latest version, ran the ndm install, fired up the index.html, cleared the editor and began building the spec. All is going well until I want to test my first path against the vendors root (no authentication) which should just return some HTML but I am getting the following which I see other users experiencing... The HTTPS URL being built by Swagger Editor is correct...copy/pasted into another tab. What am I missing or what may I have missed installing the local Swagger Editor? Again, sorry I'm just a noob and trying to learn this. This spec would help me immensely if I can get it into my Salesforce Dev Org! Thanks in advance for the help! ------JimSolvedsmartbear.com CORS error when importing file/URL
Hello, I am running swagger editor in docker on a remote machine and accessing it at localhost at port 8090 via a tunnel. I am also hosting my openapi spec files on a remote http server accessible locally at port 8095 via a tunnel. $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fe6c49889c03 myhttpd "httpd-foreground" 20 hours ago Up 20 hours 0.0.0.0:8095->80/tcp, :::8095->80/tcp my-httpd c365e0c63a6d swaggerapi/swagger-editor:v5.0.0-alpha.88-unprivileged "/docker-entrypoint.…" 23 hours ago Up 23 hours 0.0.0.0:8090->8080/tcp, :::8090->8080/tcp dreamy_wu When I import the main OAS file http://localhost:8095/openapi-test.yaml which uses remote refs, content is loaded but the editor reports CORS errors for incorrect resource refhttps://smartbear.com/openapi-test-comp.yaml The correct ref URL would be https://localhost:8095/openapi-test-comp.yaml as seen below in the browser: Any suggestion on how to avoid/resolve this error? Thanks openapi-test.yaml: openapi: 3.0.3 info: title: Test - OpenAPI 3.0 description: |- _draft_ termsOfService: http://swagger.io/terms/ contact: email: apiteam@test.com license: name: Apache 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html version: 1.0.0 paths: /api/orders/{orderId}: put: tags: - test summary: Update an order description: Update an order operationId: updateOrder parameters: - $ref: 'openapi-test-comp.yaml#/components/parameters/apiKey' - $ref: 'openapi-test-comp.yaml#/components/parameters/orderId' requestBody: $ref: "openapi-test-comp.yaml#/components/requestBodies/order" responses: '200': description: Successful operation content: application/json: schema: oneOf: - $ref: 'openapi-test-comp.yaml#/components/schemas/order' application/xml: schema: oneOf: - $ref: 'openapi-test-comp.yaml#/components/schemas/order' '400': description: Invalid ID supplied '404': description: Order not found '422': description: Validation exception security: - test_auth: - write:order - read:order components: parameters: apiKey: name: api_key in: header description: '' required: true schema: type: string example: "7885007453a84ba59aa846b27ad7deb0" orderId: name: orderId in: path description: ID of order required: true schema: type: string schemas: order: type: object required: - id - name properties: id: type: string example: 5d7d95a7-1d0e-4493-9558-0ad621b69ac5 name: type: string ApiResponse: type: object properties: code: type: integer format: int32 type: type: string message: type: string xml: name: '##default' requestBodies: order: description: order that needs to be added required: true content: application/json: schema: oneOf: - $ref: 'openapi-test-comp.yaml#/components/schemas/order' application/xml: schema: oneOf: - $ref: 'openapi-test-comp.yaml#/components/schemas/order' application/x-www-form-urlencoded: schema: oneOf: - $ref: 'openapi-test-comp.yaml#/components/schemas/order' securitySchemes: test_auth: type: oauth2 flows: implicit: authorizationUrl: https://test.com/authorize scopes: write:order: modify order read:order: read order api_key: type: apiKey name: api_key in: header openapi-test-comp.yaml: components: parameters: apiKey: name: api_key in: header description: '' required: true schema: type: string example: "7885007453a84ba59aa846b27ad7deb0" orderId: name: orderId in: path description: ID of order required: true schema: type: string schemas: order: type: object required: - id - name properties: id: type: string example: 5d7d95a7-1d0e-4493-9558-0ad621b69ac5 name: type: string ApiResponse: type: object properties: code: type: integer format: int32 type: type: string message: type: string xml: name: '##default' requestBodies: order: description: order that needs to be added required: true content: application/json: schema: oneOf: - $ref: '#/components/schemas/order' application/xml: schema: oneOf: - $ref: '#/components/schemas/order' application/x-www-form-urlencoded: schema: oneOf: - $ref: '#/components/schemas/order' securitySchemes: test_auth: type: oauth2 flows: implicit: authorizationUrl: https://test.com/authorize scopes: write:order: modify order read:order: read order api_key: type: apiKey name: api_key in: headerAbout publishing and deleting data entered online
The following operations were performed using the online Swagger Editor (https://editor.swagger.io/). I have a question about how to handle edited data in this case. operation 1. Access the site below https://swagger.io/tools/swagger-editor/ 2. Click "Try Swagger Editor" Paste the API specification in the left area Click “Create server” ⇒ “nodejs-server” in the menu Question 1. Is there a possibility that it will be disclosed to a third party? Question 2. Will the data remain on the cloud side? If any remain, please delete them. *Reply request:October 18thDocumenting an API with all operations under a single path
I'm trying to document an existing API that uses a single path with query parameters to specify the different actions: /api?action=action1&some-param=1 /api?action=action2&other-aparam=2 If I would put all parameters under a single path, that would force all parameters under that path, too and would mix a lot of parameters that are only valid on certain actions. The Swagger editor doesn't let me create multiple entries for the same path, even if the action parameter is required with a different value on each. and doesn't accept /api?action=action1 as a separate path either. Is the unique path a requirement from Swagger or from the OpenAPI spec ? Is there a good workaround how to handle this ? Thanks!