question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect validation message for unique operationId

See original GitHub issue
Q 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:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
shockeycommented, Jan 22, 2018

@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.

0reactions
jemeraldcommented, Apr 17, 2018

@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:

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found