Skip to content

Commit

Permalink
Revert "Merge branch 'develop' of https://github.com/trimble-oss/open…
Browse files Browse the repository at this point in the history
…api-spectral-rules into develop"

This reverts commit 4c63c33, reversing
changes made to c3b1abb.
  • Loading branch information
sgomath committed Aug 3, 2023
1 parent 4c63c33 commit d12a07d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 146 deletions.
14 changes: 1 addition & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
"@stoplight/spectral-functions": "^1.7.2",
"@stoplight/spectral-ruleset-migrator": "^1.9.1",
"@stoplight/spectral-rulesets": "^1.14.1",

"jest": "^29.4.0",
"pos": "^0.4.2"
"jest": "^29.4.0"
},
"dependencies": {
"markdown-toc": "^1.2.0"
Expand Down
130 changes: 0 additions & 130 deletions spectral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,142 +2,12 @@ extends:
- [spectral:oas, all]
functionsDir: "./functions"
functions:

- valid-url-checker
- valid-version-checker
- is-a-plural-noun
- no-http-verbs-in-path
- check-if-application-or-json-in-put-and-post-response
- check-if-response-body-json-in-get-response
- valid-http-response
- check-for-query-parameter-in-every-path
- does-spec-contains-valid-http-verbs
- is-valid-spec

- operation-summary-description
- operation-post-201-202-status-code

rules:
no-$ref-siblings: off


# Server URLs should follow Trimble API Standards presented in Cloud URL Structure Summary
# https://api-standards.trimble-pnp.com/api-standard/http#url-structure
tas-api-server-url-invalid:
description: API URLs should meet the Trimble API Standards
message: "{{error}}"
given: "$.servers"
severity: warn
then:
function: valid-url-checker

# API Version must include the major version and MUST NOT include the minor version
# https://api-standards.trimble-pnp.com/api-standard/http#url-versioning
tas-api-server-url-version-invalid:
description: API URLs versions should meet the Trimble API Standards
message: "{{error}}"
given: "$.servers"
severity: warn
then:
function: valid-version-checker

# Resource names in the URL must be a noun
# https://api-standards.trimble-pnp.com/api-standard/http#resource-naming
tas-api-paths-should-start-with-a-noun:
description: The root resource name in the URL MUST be a noun and MUST be in the plural form. Further nouns MAY be in the singular.
message: "{{error}}"
given: "$.paths"
severity: error
then:
field: "@key"
function: is-a-plural-noun

# All schema property names should be camel case.
# https://api-standards.trimble-pnp.com/api-standard/http#field-names
tas-openapi-v3-schema-properties-names-camel-case:
description: Ensuring that schema property names are camel case.
message: All schema property names should be camel case.
severity: error
given: "$..properties.."
then:
field: "@key"
function: pattern
functionOptions:
match: "^[a-z][a-zA-Z0-9]*$"
errorMessage: All field names MUST be formatted as camel case.

# Resource path should not contain HTTP verbs
# https://api-standards.trimble-pnp.com/api-standard/http#avoiding-actions-in-resource-names
tas-no-http-verbs-in-path:
description: HTTP verbs should be not be in URL paths
message: "{{property}} has HTTP verb in path: {{error}}"
recommended: true
type: style
given: "$.paths"
then:
field: "@key"
function: no-http-verbs-in-path

# All APIs returning structured data should support JSON as the default format
# https://api-standards.trimble-pnp.com/api-standard/http#data-from-apis-bodies-returned-from-gets-posts-puts
tas-structured-data-format:
description: All APIs returning structured data should support JSON as the default format.
severity: error
message: "{{error}}"
given: "$.paths.*."
then:
function: check-if-application-or-json-in-put-and-post-response

# All APIs returning structured data should support JSON as the default format.
# https://api-standards.trimble-pnp.com/api-standard/http#data-from-apis-bodies-returned-from-gets-posts-puts
tas-structured-data-format-support-json-response-body:
description: All APIs returning structured data should support JSON as the default format.
severity: error
message: "{{error}}"
given: "$.paths.*."
then:
function: check-if-response-body-json-in-get-response

# All APIs should return a valid http response code (Additional ruleset)
tdp-http-response-code:
description: All APIs should return a valid http response code.
severity: warn
message: "{{error}}"
given: "$..responses"
then:
field: "@key"
function: valid-http-response

# Resource path should not contain query parameter
# https://api-standards.trimble-pnp.com/api-standard/http#url-parameters
tas-check-queryparameter-in-endpoint:
description: Check if the given resource path has queryparameter.
severity: warn
message: "{{error}}"
given: "$.paths"
then:
field: "@key"
function: check-for-query-parameter-in-every-path

# Spec should contain only valid http verbs (Additional ruleset)
tdp-does-spec-contains-valid-http-verbs:
description: All APIs should have a valid http verb.
severity: warn
message: "{{error}}"
given: "$.paths.*"
then:
field: "@key"
function: does-spec-contains-valid-http-verbs

# Restrict empty spec(Additional ruleset)
tdp-spec-should-not-be-empty:
description: Spec should not be empty.
severity: error
message: "{{error}}"
given: "$"
then:
function: is-valid-spec

# Reject Pascal Case within tags
tdp-tag-pascal-case:
severity: warn
Expand Down

0 comments on commit d12a07d

Please sign in to comment.