Skip to content

Commit b7fafe2

Browse files
author
Mike Kistler
committed
fix: Fix operationID case convention to match API Handbook (lower_snake_case)
1 parent 42eeaab commit b7fafe2

File tree

9 files changed

+30
-30
lines changed

9 files changed

+30
-30
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ The default values for each rule are described below.
329329
| Rule | Default |
330330
| ---------------------------- | ------- |
331331
| no_operation_id | warning |
332-
| operation_id_case_convention | warning, lower_camel_case |
332+
| operation_id_case_convention | warning, lower_snake_case |
333333
| no_summary | warning |
334334
| no_array_responses | error |
335335
| parameter_order | warning |

src/.defaultsForValidator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const defaults = {
2222
'shared': {
2323
'operations': {
2424
'no_operation_id': 'warning',
25-
'operation_id_case_convention': ['warning', 'lower_camel_case'],
25+
'operation_id_case_convention': ['warning', 'lower_snake_case'],
2626
'no_summary': 'warning',
2727
'no_array_responses': 'error',
2828
'parameter_order': 'warning'

test/cli-validator/mockFiles/clean.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ paths:
3333
- "pet"
3434
summary: "Add a new pet to the store"
3535
description: "post a pet to store"
36-
operationId: "addPet"
36+
operationId: "add_pet"
3737
consumes:
3838
- "application/json"
3939
- "application/xml"
@@ -59,7 +59,7 @@ paths:
5959
- "pet"
6060
summary: "Update an existing pet"
6161
description: "put new data for existing pet"
62-
operationId: "updatePet"
62+
operationId: "update_pet"
6363
consumes:
6464
- "application/json"
6565
- "application/xml"
@@ -90,7 +90,7 @@ paths:
9090
- "pet"
9191
summary: "Finds Pets by status"
9292
description: "Multiple status values can be provided with comma separated strings"
93-
operationId: "findPetsByStatus"
93+
operationId: "find_pets_by_status"
9494
produces:
9595
- "application/xml"
9696
- "application/json"

test/cli-validator/mockFiles/cleanWithTabs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ paths:
3333
- "pet"
3434
summary: "Add a new pet to the store"
3535
description: "post a pet to store"
36-
operationId: "addPet"
36+
operationId: "add_pet"
3737
consumes:
3838
- "application/json"
3939
- "application/xml"
@@ -59,7 +59,7 @@ paths:
5959
- "pet"
6060
summary: "Update an existing pet"
6161
description: "put new data for existing pet"
62-
operationId: "updatePet"
62+
operationId: "update_pet"
6363
consumes:
6464
- "application/json"
6565
- "application/xml"
@@ -90,7 +90,7 @@ paths:
9090
- "pet"
9191
summary: "Finds Pets by status"
9292
description: "Multiple status values can be provided with comma separated strings"
93-
operationId: "findPetsByStatus"
93+
operationId: "find_pets_by_status"
9494
produces:
9595
- "application/xml"
9696
- "application/json"

test/cli-validator/mockFiles/errAndWarn.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ paths:
8484
- "pet"
8585
summary: "Finds Pets by status"
8686
description: "Multiple status values can be provided with comma separated strings"
87-
operationId: "findPetsByStatus"
87+
operationId: "find_pets_by_status"
8888
produces:
8989
- "application/xml"
9090
- "application/json"

test/cli-validator/mockFiles/justWarn.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ paths:
5959
- "pet"
6060
summary: "Update an existing pet"
6161
description: "put new data for existing pet"
62-
operationId: "updatePet"
62+
operationId: "update_pet"
6363
consumes:
6464
- "application/json"
6565
- "application/xml"
@@ -90,7 +90,7 @@ paths:
9090
- "pet"
9191
summary: "Finds Pets by status"
9292
description: "Multiple status values can be provided with comma separated strings"
93-
operationId: "findPetsByStatus"
93+
operationId: "find_pets_by_status"
9494
produces:
9595
- "application/xml"
9696
- "application/json"

test/cli-validator/mockFiles/oas3/clean.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ paths:
1010
/pets:
1111
get:
1212
summary: List all pets
13-
operationId: listPets
13+
operationId: list_pets
1414
tags:
1515
- pets
1616
parameters:
@@ -41,7 +41,7 @@ paths:
4141
$ref: "#/components/schemas/Error"
4242
post:
4343
summary: Create a pet
44-
operationId: createPets
44+
operationId: create_pets
4545
tags:
4646
- pets
4747
responses:
@@ -56,7 +56,7 @@ paths:
5656
/pets/{pet_id}:
5757
get:
5858
summary: Info for a specific pet
59-
operationId: showPetById
59+
operationId: show_pet_by_id
6060
tags:
6161
- pets
6262
parameters:

test/cli-validator/mockFiles/trailingComma.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"/v1/thing": {
1717
"post": {
1818
"summary": "Create a thing.",
19-
"operationId": "createThing",
19+
"operationId": "create_thing",
2020
"consumes": [
2121
"multipart/form-data"
2222
],

test/plugins/validation/2and3/operations-shared.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('validation plugin - semantic - operations-shared', function() {
1313
paths: {
1414
'/': {
1515
get: {
16-
operationId: 'getEverything',
16+
operationId: 'get_everything',
1717
summary: 'this is a summary',
1818
parameters: [
1919
{
@@ -120,7 +120,7 @@ describe('validation plugin - semantic - operations-shared', function() {
120120
'/CoolPath': {
121121
put: {
122122
consumes: ['consumes'],
123-
operationId: 'operationId',
123+
operationId: 'operation_id',
124124
parameters: [
125125
{
126126
name: 'BadParameter',
@@ -156,7 +156,7 @@ describe('validation plugin - semantic - operations-shared', function() {
156156
put: {
157157
consumes: ['consumes'],
158158
summary: ' ',
159-
operationId: 'operationId',
159+
operationId: 'operation_id',
160160
parameters: [
161161
{
162162
name: 'BadParameter',
@@ -222,7 +222,7 @@ describe('validation plugin - semantic - operations-shared', function() {
222222
'/stuff': {
223223
get: {
224224
summary: 'list stuff',
225-
operationId: 'listStuff',
225+
operationId: 'list_stuff',
226226
produces: ['application/json'],
227227
responses: {
228228
200: {
@@ -257,7 +257,7 @@ describe('validation plugin - semantic - operations-shared', function() {
257257
'/stuff': {
258258
get: {
259259
summary: 'list stuff',
260-
operationId: 'listStuff',
260+
operationId: 'list_stuff',
261261
produces: ['application/json'],
262262
responses: {
263263
200: {
@@ -300,7 +300,7 @@ describe('validation plugin - semantic - operations-shared', function() {
300300
'x-vendor-put-op': {
301301
consumes: ['consumes'],
302302
summary: ' ',
303-
operationId: 'operationId',
303+
operationId: 'operation_id',
304304
parameters: [
305305
{
306306
name: 'BadParameter',
@@ -331,7 +331,7 @@ describe('validation plugin - semantic - operations-shared', function() {
331331
'/stuff': {
332332
get: {
333333
summary: 'list stuff',
334-
operationId: 'listStuff',
334+
operationId: 'list_stuff',
335335
produces: ['application/json'],
336336
parameters: [
337337
{
@@ -375,7 +375,7 @@ describe('validation plugin - semantic - operations-shared', function() {
375375
'/stuff': {
376376
get: {
377377
summary: 'list stuff',
378-
operationId: 'listStuff',
378+
operationId: 'list_stuff',
379379
produces: ['application/json'],
380380
parameters: [
381381
{
@@ -432,7 +432,7 @@ describe('validation plugin - semantic - operations-shared', function() {
432432
'/fake/{id}': {
433433
get: {
434434
summary: 'get fake data by id',
435-
operationId: 'getFakeData',
435+
operationId: 'get_fake_data',
436436
produces: ['application/json'],
437437
parameters: [
438438
{
@@ -492,7 +492,7 @@ describe('validation plugin - semantic - operations-shared', function() {
492492
'/fake/{id}': {
493493
get: {
494494
summary: 'get fake data by id',
495-
operationId: 'getFakeData',
495+
operationId: 'get_fake_data',
496496
produces: ['application/json'],
497497
parameters: [
498498
{
@@ -553,7 +553,7 @@ describe('validation plugin - semantic - operations-shared', function() {
553553
put: {
554554
consumes: ['consumes'],
555555
summary: 'this is a summary',
556-
operationId: 'cool_path_put',
556+
operationId: 'coolPathPut',
557557
parameters: [
558558
{
559559
name: 'BadParameter',
@@ -577,7 +577,7 @@ describe('validation plugin - semantic - operations-shared', function() {
577577
expect(res.warnings.length).toEqual(1);
578578
expect(res.warnings[0].path).toEqual('paths./CoolPath.put.operationId');
579579
expect(res.warnings[0].message).toEqual(
580-
'operationIds must follow case convention: lower_camel_case'
580+
'operationIds must follow case convention: lower_snake_case'
581581
);
582582
expect(res.errors.length).toEqual(0);
583583
});
@@ -589,7 +589,7 @@ describe('validation plugin - semantic - operations-shared', function() {
589589
put: {
590590
consumes: ['consumes'],
591591
summary: 'this is a summary',
592-
operationId: 'coolPathPut',
592+
operationId: 'cool_path_put',
593593
parameters: [
594594
{
595595
name: 'BadParameter',
@@ -633,7 +633,7 @@ describe('validation plugin - semantic - operations-shared', function() {
633633
paths: {
634634
'/': {
635635
get: {
636-
operationId: 'getEverything',
636+
operationId: 'get_everything',
637637
summary: 'this is a summary',
638638
responses: {
639639
default: {
@@ -679,7 +679,7 @@ describe('validation plugin - semantic - operations-shared', function() {
679679
paths: {
680680
'/': {
681681
get: {
682-
operationId: 'getEverything',
682+
operationId: 'get_everything',
683683
summary: 'get everything as a string or an array',
684684
responses: {
685685
'200': {

0 commit comments

Comments
 (0)