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

Api 31084 api standards ruleset environment urls in descriptions #177

Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 10 additions & 1 deletion src/suites/rulesets/lighthouse-api-standards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,13 @@ rules:
then:
function: pattern
functionOptions:
notMatch: /[_]/
notMatch: /[_]/

va-openapi-description-invalid-url:
description: Descriptions must not contain URLs that reference a particular environment such as https://dev-developer.va.gov or https://developer.va.gov.
severity: error
given: $..*.description
then:
function: pattern
functionOptions:
notMatch: /(http:\/\/|https:\/\/)?([\-\][a-z0-9]+)*?(developer\.va\.gov)/ig
7 changes: 6 additions & 1 deletion test/suites/rulesets/fixtures/setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"va-endpoint-default-errors-service-unavailable": ["If an upstream service outage could cause your API to throw a 500 error, consider catching it and raising a 503 instead."],
"va-endpoint-default-errors-gateway-timeout": ["If your API is not receiving a timely response from an upstream service and could cause it to throw a 500 error, consider catching it and raising a 504 instead."],
"va-servers-url-contains-no-underscores": ["Base (server) URLs must use dashes rather than underscores for spaces in words."],
"va-paths-contain-no-underscores": ["Paths must use dashes rather than underscores for spaces in words."]
"va-paths-contain-no-underscores": ["Paths must use dashes rather than underscores for spaces in words."],
"va-openapi-description-invalid-url": ["Descriptions must not contain URLs that reference a particular environment such as https://dev-developer.va.gov or https://developer.va.gov.",
"Descriptions must not contain URLs that reference a particular environment such as https://dev-developer.va.gov or https://developer.va.gov.",
"Descriptions must not contain URLs that reference a particular environment such as https://dev-developer.va.gov or https://developer.va.gov.",
"Descriptions must not contain URLs that reference a particular environment such as https://dev-developer.va.gov or https://developer.va.gov.",
"Descriptions must not contain URLs that reference a particular environment such as https://dev-developer.va.gov or https://developer.va.gov."]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"openapi": "3.0.1",
"info": {
"description": "This description contains a URL with an environment reference https://developer.va.gov/explore/api/some-api/docs"
},
"servers": [
{
"url": "https://sandbox-api.va.gov/services/some-api/{version}",
"description": "This description contains a URL with an environment reference https://developer.va.gov/explore/api/some-api/docs",
"variables": {
"version": {
"default": "v1"
}
}
},
{
"url": "https://api.va.gov/services/some-api/{version}",
"description": "Production",
"variables": {
"version": {
"default": "v1"
}
}
}
],
"tags": [
],
"paths": {
"/onePathExist": {
"get":{
"tags": [],
"summary": "",
"description": "This description contains a URL with an environment reference https://staging-developer.va.gov/explore/api/some-api/docs",
"parameters": [],
"responses": {}
}
}
},
"components": {
"securitySchemes": {
"productionOauth": {
"type": "oauth2",
"description": "This description contains a URL with an environment reference https://dev-developer.va.gov/explore/api/some-api/auth",
"flows": {}
},
"sandboxOauth": {
"type": "oauth2",
"description": "This description contains a URL with an environment reference https://dev-developer.va.gov/explore/api/some-api/auth",
"flows": {}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"openapi": "3.0.1",
"info": {
"description": "This description does not contain a URL with an environment reference /explore/api/some-api/docs"
},
"servers": [
{
"url": "https://sandbox-api.va.gov/services/some-api/{version}",
"description": "This description does not contain a URL with an environment reference /explore/api/some-api/docs",
"variables": {
"version": {
"default": "v1"
}
}
},
{
"url": "https://api.va.gov/services/some-api/{version}",
"description": "Production",
"variables": {
"version": {
"default": "v1"
}
}
}
],
"tags": [
],
"paths": {
"/onePathExist": {
"get":{
"tags": [],
"summary": "",
"description": "This description does not contain a URL with an environment reference /explore/api/some-api/docs",
"parameters": [],
"responses": {}
}
}
},
"components": {
"securitySchemes": {
"productionOauth": {
"type": "oauth2",
"description": "This description does not contain a URL with an environment reference /explore/api/some-api/auth",
"flows": {}
},
"sandboxOauth": {
"type": "oauth2",
"description": "This description does not contain a URL with an environment reference /explore/api/some-api/auth",
"flows": {}
}
}
}
}