Skip to content

Commit

Permalink
fix: Fix operationID case convention to match API Handbook (lower_sna…
Browse files Browse the repository at this point in the history
…ke_case)
  • Loading branch information
Mike Kistler committed Apr 19, 2019
1 parent 42eeaab commit b7fafe2
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ The default values for each rule are described below.
| Rule | Default |
| ---------------------------- | ------- |
| no_operation_id | warning |
| operation_id_case_convention | warning, lower_camel_case |
| operation_id_case_convention | warning, lower_snake_case |
| no_summary | warning |
| no_array_responses | error |
| parameter_order | warning |
Expand Down
2 changes: 1 addition & 1 deletion src/.defaultsForValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const defaults = {
'shared': {
'operations': {
'no_operation_id': 'warning',
'operation_id_case_convention': ['warning', 'lower_camel_case'],
'operation_id_case_convention': ['warning', 'lower_snake_case'],
'no_summary': 'warning',
'no_array_responses': 'error',
'parameter_order': 'warning'
Expand Down
6 changes: 3 additions & 3 deletions test/cli-validator/mockFiles/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ paths:
- "pet"
summary: "Add a new pet to the store"
description: "post a pet to store"
operationId: "addPet"
operationId: "add_pet"
consumes:
- "application/json"
- "application/xml"
Expand All @@ -59,7 +59,7 @@ paths:
- "pet"
summary: "Update an existing pet"
description: "put new data for existing pet"
operationId: "updatePet"
operationId: "update_pet"
consumes:
- "application/json"
- "application/xml"
Expand Down Expand Up @@ -90,7 +90,7 @@ paths:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus"
operationId: "find_pets_by_status"
produces:
- "application/xml"
- "application/json"
Expand Down
6 changes: 3 additions & 3 deletions test/cli-validator/mockFiles/cleanWithTabs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ paths:
- "pet"
summary: "Add a new pet to the store"
description: "post a pet to store"
operationId: "addPet"
operationId: "add_pet"
consumes:
- "application/json"
- "application/xml"
Expand All @@ -59,7 +59,7 @@ paths:
- "pet"
summary: "Update an existing pet"
description: "put new data for existing pet"
operationId: "updatePet"
operationId: "update_pet"
consumes:
- "application/json"
- "application/xml"
Expand Down Expand Up @@ -90,7 +90,7 @@ paths:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus"
operationId: "find_pets_by_status"
produces:
- "application/xml"
- "application/json"
Expand Down
2 changes: 1 addition & 1 deletion test/cli-validator/mockFiles/errAndWarn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ paths:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus"
operationId: "find_pets_by_status"
produces:
- "application/xml"
- "application/json"
Expand Down
4 changes: 2 additions & 2 deletions test/cli-validator/mockFiles/justWarn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ paths:
- "pet"
summary: "Update an existing pet"
description: "put new data for existing pet"
operationId: "updatePet"
operationId: "update_pet"
consumes:
- "application/json"
- "application/xml"
Expand Down Expand Up @@ -90,7 +90,7 @@ paths:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus"
operationId: "find_pets_by_status"
produces:
- "application/xml"
- "application/json"
Expand Down
6 changes: 3 additions & 3 deletions test/cli-validator/mockFiles/oas3/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ paths:
/pets:
get:
summary: List all pets
operationId: listPets
operationId: list_pets
tags:
- pets
parameters:
Expand Down Expand Up @@ -41,7 +41,7 @@ paths:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
operationId: create_pets
tags:
- pets
responses:
Expand All @@ -56,7 +56,7 @@ paths:
/pets/{pet_id}:
get:
summary: Info for a specific pet
operationId: showPetById
operationId: show_pet_by_id
tags:
- pets
parameters:
Expand Down
2 changes: 1 addition & 1 deletion test/cli-validator/mockFiles/trailingComma.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"/v1/thing": {
"post": {
"summary": "Create a thing.",
"operationId": "createThing",
"operationId": "create_thing",
"consumes": [
"multipart/form-data"
],
Expand Down
30 changes: 15 additions & 15 deletions test/plugins/validation/2and3/operations-shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('validation plugin - semantic - operations-shared', function() {
paths: {
'/': {
get: {
operationId: 'getEverything',
operationId: 'get_everything',
summary: 'this is a summary',
parameters: [
{
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('validation plugin - semantic - operations-shared', function() {
'/CoolPath': {
put: {
consumes: ['consumes'],
operationId: 'operationId',
operationId: 'operation_id',
parameters: [
{
name: 'BadParameter',
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('validation plugin - semantic - operations-shared', function() {
put: {
consumes: ['consumes'],
summary: ' ',
operationId: 'operationId',
operationId: 'operation_id',
parameters: [
{
name: 'BadParameter',
Expand Down Expand Up @@ -222,7 +222,7 @@ describe('validation plugin - semantic - operations-shared', function() {
'/stuff': {
get: {
summary: 'list stuff',
operationId: 'listStuff',
operationId: 'list_stuff',
produces: ['application/json'],
responses: {
200: {
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('validation plugin - semantic - operations-shared', function() {
'/stuff': {
get: {
summary: 'list stuff',
operationId: 'listStuff',
operationId: 'list_stuff',
produces: ['application/json'],
responses: {
200: {
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('validation plugin - semantic - operations-shared', function() {
'x-vendor-put-op': {
consumes: ['consumes'],
summary: ' ',
operationId: 'operationId',
operationId: 'operation_id',
parameters: [
{
name: 'BadParameter',
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('validation plugin - semantic - operations-shared', function() {
'/stuff': {
get: {
summary: 'list stuff',
operationId: 'listStuff',
operationId: 'list_stuff',
produces: ['application/json'],
parameters: [
{
Expand Down Expand Up @@ -375,7 +375,7 @@ describe('validation plugin - semantic - operations-shared', function() {
'/stuff': {
get: {
summary: 'list stuff',
operationId: 'listStuff',
operationId: 'list_stuff',
produces: ['application/json'],
parameters: [
{
Expand Down Expand Up @@ -432,7 +432,7 @@ describe('validation plugin - semantic - operations-shared', function() {
'/fake/{id}': {
get: {
summary: 'get fake data by id',
operationId: 'getFakeData',
operationId: 'get_fake_data',
produces: ['application/json'],
parameters: [
{
Expand Down Expand Up @@ -492,7 +492,7 @@ describe('validation plugin - semantic - operations-shared', function() {
'/fake/{id}': {
get: {
summary: 'get fake data by id',
operationId: 'getFakeData',
operationId: 'get_fake_data',
produces: ['application/json'],
parameters: [
{
Expand Down Expand Up @@ -553,7 +553,7 @@ describe('validation plugin - semantic - operations-shared', function() {
put: {
consumes: ['consumes'],
summary: 'this is a summary',
operationId: 'cool_path_put',
operationId: 'coolPathPut',
parameters: [
{
name: 'BadParameter',
Expand All @@ -577,7 +577,7 @@ describe('validation plugin - semantic - operations-shared', function() {
expect(res.warnings.length).toEqual(1);
expect(res.warnings[0].path).toEqual('paths./CoolPath.put.operationId');
expect(res.warnings[0].message).toEqual(
'operationIds must follow case convention: lower_camel_case'
'operationIds must follow case convention: lower_snake_case'
);
expect(res.errors.length).toEqual(0);
});
Expand All @@ -589,7 +589,7 @@ describe('validation plugin - semantic - operations-shared', function() {
put: {
consumes: ['consumes'],
summary: 'this is a summary',
operationId: 'coolPathPut',
operationId: 'cool_path_put',
parameters: [
{
name: 'BadParameter',
Expand Down Expand Up @@ -633,7 +633,7 @@ describe('validation plugin - semantic - operations-shared', function() {
paths: {
'/': {
get: {
operationId: 'getEverything',
operationId: 'get_everything',
summary: 'this is a summary',
responses: {
default: {
Expand Down Expand Up @@ -679,7 +679,7 @@ describe('validation plugin - semantic - operations-shared', function() {
paths: {
'/': {
get: {
operationId: 'getEverything',
operationId: 'get_everything',
summary: 'get everything as a string or an array',
responses: {
'200': {
Expand Down

0 comments on commit b7fafe2

Please sign in to comment.