Skip to content

Conversation

@jemerald
Copy link
Contributor

Description

The previous code was looping through all known operations and update their __originalOperationId and operationId, after each one operation is added to the known list.

This is not only inefficient, but introduces a bug at the following line

obj.__originalOperationId = obj.__originalOperationId || operation.operationId

Where operation is the one that just got added and obj is the current operation in the loop.

This means for the following spec:

        const spec = {spec: {
          paths: {
            '/foo': {
              get: {
              },
              post: {
                operationId: 'myId2'
              }
            },
          }
        }}

When operationId is not defined for the get operation, the __originalOperationId incorrectly gets set to 'myId2' when the post operation got added to the list.

Motivation and Context

Fixes #1221

How Has This Been Tested?

Added extra unit test to cover the above scenario

Screenshots (if appropriate):

Types of changes

  • No code changes (changes to documentation, CI, metadata, etc)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@shockey shockey self-assigned this Jan 15, 2018
@shockey shockey added this to the January 19, 2018 milestone Jan 15, 2018
@shockey shockey merged commit 242ef2b into swagger-api:master Jan 19, 2018
@shockey
Copy link
Contributor

shockey commented Jan 19, 2018

Good catch. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect setting __originalOperationId when operationId was not defined

2 participants