Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add operationId field to OpenAPI output #5876

Merged
merged 4 commits into from
Dec 12, 2018
Merged

Add operationId field to OpenAPI output #5876

merged 4 commits into from
Dec 12, 2018

Conversation

kalafut
Copy link
Contributor

@kalafut kalafut commented Nov 29, 2018

Fixes #5842

@kalafut kalafut changed the title Add operationId field to OpenAPI output [Review Only] Add operationId field to OpenAPI output Nov 29, 2018
@kalafut
Copy link
Contributor Author

kalafut commented Nov 29, 2018

@jefferai It looks like unique within a document is by far the most common interpretation, but there have been questions to the OAS group about tightening up what the operationId uniqueness scope is. There are likely cases where you would would the exact same definitions uniquely defined.

To that end I've added an optional "context" parameter (naming improvements?), that the requester can provide which will be added to the generated ID. If this approach is OK, I'll update/add tests.

@kalafut kalafut added this to the 1.0.1 milestone Nov 29, 2018
@kalafut kalafut changed the title [Review Only] Add operationId field to OpenAPI output Add operationId field to OpenAPI output Dec 12, 2018
@kalafut kalafut requested review from ncabatoff and removed request for ncabatoff December 12, 2018 20:25
operationIDs[opID] += 1
opID = fmt.Sprintf("%s_%d", opID, n)
} else {
operationIDs[opID] = 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 1 instead? Otherwise the above += 1 will result in 3 for the next duplicate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's behaves as expected (since n is used in the printf), but the code is awkward. I just pushed a change that simplifies it.

briankassouf
briankassouf previously approved these changes Dec 12, 2018
Copy link
Contributor

@briankassouf briankassouf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just the one small comment

@kalafut kalafut merged commit ffb61ea into master Dec 12, 2018
@kalafut kalafut deleted the operation-id branch December 12, 2018 21:59
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.

3 participants