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 linting implementation guideline (#1) #110

Conversation

ravindrapalaskar17
Copy link
Collaborator

@ravindrapalaskar17 ravindrapalaskar17 commented Dec 11, 2023

What type of PR is this?

  • enhancement/feature
  • documentation

What this PR does / why we need it:

This PR introduces a step-by-step process to integrate Spectral linting into the CAMARA Repository.

The integration is essential for validating the API specification design in accordance with CAMARA's API specification guidelines.

The changes encompass both source code modifications and documentation enhancements to ensure a seamless integration of Spectral linting.

Which issue(s) this PR fixes:

Fixes #15

* Create .spectral.yml

* Create camara-language-avoid-telco.js

* Create camara-reserved-words.js

* Create camara-security-no-secrets-in-path-or-query-parameters.js

* Create megalinter.yml

* Create API-linting-Implementation-Guideline.md

* update API linting document files with new links of files

* Update API-linting-Implementation-Guideline.md

* Create javalint.xml

* Create .yamllint.yaml

* reserved word 'enum' and 'default' are removed from reserved word array

* Remove reserved words from arrays: openAPIKeywords and reservedWords"

* Enable recommended option true/false for each rule.

* Update log of telco rule

* Update log of reserved word rule

* Update  log of camara-security-no-secrets-in-path-or-query-parameters.js

* update custom function rule name

* update rule name as per camara standards
@eric-murray
Copy link
Collaborator

I had to make two changes to .yamllint.yaml get this to work in Device Identifiers:

  ...
  comments:
    min-spaces-from-content: 1
  ...
  new-lines: disable

The problem with the "not enough spaces before comment" error was in megalinter.yml itself, so not a problem with the YAML.

I don't know why there was a perceived problem with the newline character in the YAML, but I didn't think it was an issue so disabled that check.

Copy link
Contributor

@jlurien jlurien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very complete guideline, thanks. We may need some versioning headers in the files if the idea is to copy this content in each repository, so subprojects can detect changes in Commonalities' artifact

documentation/API-linting-Implementation-Guideline.md Outdated Show resolved Hide resolved
function: truthy
recommended: true # Set to true/false to enable/disable this rule

camara-discriminator-use:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

artifacts/linting_rules/.spectral.yml Outdated Show resolved Hide resolved
then:
function: pattern
functionOptions:
match: "^\/([a-z0-9]+(-[a-z0-9]+)*)?(\/[a-z0-9]+(-[a-z0-9]+)*|\/{.+})*$" # doesn't allow /asasd{asdas}sadas pattern or not closed braces
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using built-in type: kebab

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and updated PR with spectral core function kebab

* Update camara-language-avoid-telco.js

Header comment added

* Update camara-reserved-words.js

Header comment added

* Update camara-security-no-secrets-in-path-or-query-parameters.js

Header comment added

* Update .spectral.yml

Comment header added

* Update .yamllint.yaml

Header comment added

* Delete artifacts/linting_rules/javalint.xml

By default Java is not used in API specification repositories

* Update megalinter.yml

Header comment extended

* Update .yamllint.yaml

Changes in default configuration of yamllint

* Update .spectral.yml

oas3-operation-security-defined rule was disabled as it do not fully support OpenIdConnect flow

* Update megalinter.yml

Megalinter configuration change, disable not needed linters

* Update megalinter.yml

Disable running spectral outside of Megalinter

* Create spectral_oas_lint.yml

workflow configuration to manually run CAMARA OAS rules

* Update spectral_oas_lint.yml

Simplification

* Update .spectral.yml

New functions added/modified (more granularity for descriptions)

* Update .spectral.yml

typo

* Update API-linting-Implementation-Guideline.md

Modification and reshuffling of the how-to file

* Update spectral_oas_lint.yml

* Update .spectral.yml

Changed  camara-discriminator-use severity to: hint

* Update .spectral.yml

oas3-server-variables commented out

* Update megalinter.yml

Actions
checkout@v4
upload-artifact@v4
rartych
rartych previously approved these changes Feb 6, 2024
Copy link
Collaborator

@rartych rartych left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/LGTM
It is initial ruleset - subject fro further refinement

Copy link
Collaborator

@PedroDiez PedroDiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested OK within Carrier Billing and Blockchain initiatives

Custom regex including filter added for Spectral
new-lines: disable
@rartych rartych self-requested a review February 8, 2024 10:41
Copy link
Collaborator

@shilpa-padgaonkar shilpa-padgaonkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/LGTM

@rartych rartych merged commit 69caa4b into camaraproject:main Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend the API guidelines with a concrete ruleset
10 participants