Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/spectral-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
permissions:
issues: write
contents: write
checks: write

jobs:
spectral-lint:
Expand All @@ -30,15 +31,8 @@ jobs:
sparse-checkout: |
openapi/
tools/spectral
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install npm dependencies
run: npm install
- name: Fetch OAS file from Dev Branch
run: curl -O "https://raw.githubusercontent.com/mongodb/openapi/refs/heads/dev/openapi/.raw/v2.yaml"
run: curl -o dev-oas.yaml "https://raw.githubusercontent.com/mongodb/openapi/refs/heads/dev/openapi/.raw/v2.yaml"
working-directory: ${{ github.workspace }}
- name: Spectral action
uses: stoplightio/spectral-action@2ad0b9302e32a77c1caccf474a9b2191a8060d83
Expand All @@ -49,5 +43,9 @@ jobs:
- name: IPA validation action
uses: stoplightio/spectral-action@2ad0b9302e32a77c1caccf474a9b2191a8060d83
with:
file_glob: ${{ github.workspace }}//v2.yaml
file_glob: dev-oas.yaml
spectral_ruleset: tools/spectral/ipa/ipa-spectral.yaml
- name: IPA validation
run: |
npx spectral lint dev-oas.yaml --ruleset=${{ github.workspace }}/tools/spectral/ipa/ipa-spectral.yaml

Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,37 @@ testRule('xgen-IPA-102-path-alternate-resource-name-path-param', [
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/resourceName1/resourceName2'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/resourceName/{pathParam1}/{pathParam2}'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/resourceName1/{pathParam1}/resourceName2/resourceName3'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/resourceName1/{pathParam1}/resourceName2/{pathParam2}/{pathParam3}'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/{pathParam}'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/{pathParam1}/{pathParam2}'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand All @@ -100,37 +100,37 @@ testRule('xgen-IPA-102-path-alternate-resource-name-path-param', [
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/unauth/resourceName1/resourceName2'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/unauth/resourceName/{pathParam1}/{pathParam2}'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/unauth/resourceName1/{pathParam1}/resourceName2/resourceName3'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/unauth/resourceName1/{pathParam1}/resourceName2/{pathParam2}/{pathParam3}'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/unauth/{pathParam}'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-102-path-alternate-resource-name-path-param',
message: 'API paths must alternate between resource name and path params.',
path: ['paths', '/api/atlas/v2/unauth/{pathParam1}/{pathParam2}'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,31 @@ testRule('xgen-IPA-104-resource-has-GET', [
code: 'xgen-IPA-104-resource-has-GET',
message: 'APIs must provide a get method for resources.',
path: ['paths', '/standard'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-resource-has-GET',
message: 'APIs must provide a get method for resources.',
path: ['paths', '/standard/{exampleId}/nested'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-resource-has-GET',
message: 'APIs must provide a get method for resources.',
path: ['paths', '/standard/{exampleId}/nestedSingleton'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-resource-has-GET',
message: 'APIs must provide a get method for resources.',
path: ['paths', '/custom'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-resource-has-GET',
message: 'APIs must provide a get method for resources.',
path: ['paths', '/standardWithoutSubResource'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ testRule('xgen-IPA-104-get-method-no-request-body', [
code: 'xgen-IPA-104-get-method-no-request-body',
message: 'The Get method must not include a request body.',
path: ['paths', '/resource/{id}', 'get'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-no-request-body',
message: 'The Get method must not include a request body.',
path: ['paths', '/resource/{id}/singleton', 'get'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ testRule('xgen-IPA-104-get-method-response-has-no-input-fields', [
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-response-has-no-input-fields',
Expand All @@ -156,7 +156,7 @@ testRule('xgen-IPA-104-get-method-response-has-no-input-fields', [
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ testRule('xgen-IPA-104-get-method-returns-response-suffixed-object', [
'content',
'application/vnd.atlas.2023-01-01+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-returns-response-suffixed-object',
Expand All @@ -176,7 +176,7 @@ testRule('xgen-IPA-104-get-method-returns-response-suffixed-object', [
'content',
'application/vnd.atlas.2024-01-01+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-returns-response-suffixed-object',
Expand All @@ -190,7 +190,7 @@ testRule('xgen-IPA-104-get-method-returns-response-suffixed-object', [
'content',
'application/vnd.atlas.2025-01-01+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-returns-response-suffixed-object',
Expand All @@ -204,7 +204,7 @@ testRule('xgen-IPA-104-get-method-returns-response-suffixed-object', [
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-returns-single-resource',
Expand All @@ -189,7 +189,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-returns-single-resource',
Expand All @@ -204,7 +204,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-returns-single-resource',
Expand All @@ -219,7 +219,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,28 @@ testRule('xgen-IPA-104-get-method-response-code-is-200', [
message:
'The Get method must return a 200 OK response. This method either lacks a 200 OK response or defines a different 2xx status code.',
path: ['paths', '/resourceOne/{id}', 'get'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-response-code-is-200',
message:
'The Get method must return a 200 OK response. This method either lacks a 200 OK response or defines a different 2xx status code.',
path: ['paths', '/resourceTwo/{id}', 'get'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-response-code-is-200',
message:
'The Get method must return a 200 OK response. This method either lacks a 200 OK response or defines a different 2xx status code.',
path: ['paths', '/resourceThree/{id}', 'get'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-104-get-method-response-code-is-200',
message:
'The Get method must return a 200 OK response. This method either lacks a 200 OK response or defines a different 2xx status code.',
path: ['paths', '/resource/{id}/singleton', 'get'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ testRule('xgen-IPA-105-resource-has-list', [
code: 'xgen-IPA-105-resource-has-list',
message: 'APIs must provide a List method for resources.',
path: ['paths', '/standard'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-105-resource-has-list',
message: 'APIs must provide a List method for resources.',
path: ['paths', '/standard/{exampleId}/nested'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ testRule('xgen-IPA-105-list-method-no-request-body', [
code: 'xgen-IPA-105-list-method-no-request-body',
message: 'The List method must not include a request body.',
path: ['paths', '/resource', 'get'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ testRule('xgen-IPA-105-list-method-response-is-get-method-response', [
message:
'The schema of each result in the List method response must be the same schema as the response of the Get method.',
path: ['paths', '/resource', 'get', 'responses', '200', 'content', 'application/vnd.atlas.2024-08-05+json'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-105-list-method-response-is-get-method-response',
Expand All @@ -415,14 +415,14 @@ testRule('xgen-IPA-105-list-method-response-is-get-method-response', [
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-105-list-method-response-is-get-method-response',
message:
'Could not validate that the List method returns the same resource object as the Get method. The Get method does not have a schema.',
path: ['paths', '/resourceTwo', 'get', 'responses', '200', 'content', 'application/vnd.atlas.2024-01-05+json'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
{
code: 'xgen-IPA-105-list-method-response-is-get-method-response',
Expand All @@ -437,7 +437,7 @@ testRule('xgen-IPA-105-list-method-response-is-get-method-response', [
'content',
'application/vnd.atlas.2024-01-05+json',
],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down Expand Up @@ -484,7 +484,7 @@ testRule('xgen-IPA-105-list-method-response-is-get-method-response', [
message:
'The schema of each result in the List method response must be the same schema as the response of the Get method.',
path: ['paths', '/resource', 'get', 'responses', '200', 'content', 'application/vnd.atlas.2024-08-05+json'],
severity: DiagnosticSeverity.Warning,
severity: DiagnosticSeverity.Error,
},
],
},
Expand Down
Loading
Loading