Incorrect validation message for unique operationId
See original GitHub issueQ | A |
---|---|
Bug or feature request? | Bug |
Which Swagger/OpenAPI version? | 2 |
Which Swagger-Editor version? | 3.2.4 |
How did you install Swagger-Editor? | Using swagger-editor-dist with express, also reproducible in editor.swagger.io |
Which broswer & version? | Latest Chrome |
Which operating system? | Windows |
Demonstration API definition
swagger: '2.0'
info:
version: v3
title: test
basePath: /v1
paths:
/:
post:
responses:
200:
description: Successful response
get:
operationId: myId2
responses:
200:
description: Successful response
Expected Behavior
No validation error
Current Behavior
Semantic error at paths./.get.operationId Operations must have unique operationIds. Jump to line 13
Possible Solution
Added some logging to src/plugins/validate-semantic/validators/operations.js
shows that __originalOperationId
for both methods are set to “myId2”
Probably caused by this line? https://github.com/swagger-api/swagger-js/blob/master/src/helpers.js#L161
Test to be added to catch the bug
Add the following test to test/plugins/validate-semantic/operations.js
it("should not return an error when only some operationId is defined without collisions", () => {
const spec = {
paths: {
"/": {
get: {
},
post: {
operationId: "myId2"
}
}
}
}
return expectNoErrors(spec)
})
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Unreasonable Errors started to appear in SwaggerHub UI
Hi,. There is a known issue with an incorrect validation message for the unique operationId. Swagger-editor (OS) issue: https://github.
Read more >Fix Swagger Validator errors in Power Platform connectors
The Swagger Validator tool validates the connector files you ... Arrays must have unique values, but your swagger contains duplicates.
Read more >getting duplicate operationid when trying to create rest api
OperationId must be unique among all operations described in the API. I am using visual studio 2017 Azure SQL database C#. I cannot...
Read more >Custom Validation with Swagger Codegen - Baeldung
A quick and practical guide to applying custom validation to Swagger ... pets by name' operationId: findPetsByTags parameters: - <em>name: ...
Read more >Api - Amazon API Gateway
Operation ID : ReimportApi ... One of the parameters in the request is invalid. ... False. The validation information during API import.
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 Free
Top 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
@jemerald we held off on a Swagger-Editor release last Friday since it (a) had a special release last Wednesday, and (b) has no new source changes since v3.2.5.
We will cut a new release on Friday that includes the updated Swagger-Client version. If this is severely impacting your workflow, just let me know and I can run a release to get this out faster.
@rahulsaini the operationId has nothing to do with the path of your API.
See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#operation-object
For what you want to achieve, you need to put it into the path, e,g.
/searchdynamic/substtype/getModifiedTerms: