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

Enhance API documentation and enforce linting standards #201

Merged
merged 12 commits into from
Jan 5, 2024

Conversation

OhmSpectator
Copy link
Member

@OhmSpectator OhmSpectator commented Jan 5, 2024

Description

This PR introduces several enhancements to the API directory, focusing on implementing and enforcing standards through Spectral linting, updating API documentation, and improving the API definitions with proper details and organization. Key changes include setting up Spectral Linter, adding server information, updating contact and API information, adding endpoint descriptions, operation IDs, tags, and ensuring all linting warnings are treated as errors for stricter compliance.

Related Issues

Closes: #200

How Was This Tested?

  • Changes were linted locally using Spectral to ensure no issues or warnings.
  • Reviewed the updated API documentation for clarity and completeness.

Checklist

Before submitting your PR, please review the following:

  • Commit messages follow the standard template.
  • All commits are signed.
  • Related issues are mentioned in the description above.
  • I have followed the project's directory structure.
  • Linter checks have been passed.

Additional Comments (if any):

  • Future updates might include further breaking down the API specifications for scalability and manageability.
  • Continuous integration with Spectral will ensure adherence to API standards and facilitate high code quality.

Summary by CodeRabbit

  • Chores

    • Updated GitHub Actions cache keys for better differentiation in backend and frontend workflows.
    • Excluded certain files from version control in the API directory.
  • Documentation

    • Enhanced API documentation for clarity and added detailed contribution guidelines.
    • Updated API specification with new title, contact information, server details, and descriptions for operations.
  • New Features

    • Implemented Spectral API checks in GitHub Actions for improved API quality assurance.
  • Refactor

    • Extended Spectral OpenAPI Specification rules for the API.

Added Spectral Linter to the API project. This includes the necessary
devDependencies and scripts in package.json, configuration in
.spectral.yaml, and the required files in .gitignore.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
Added a GitHub Actions workflow to automatically check API definitions
with Spectral whenever a pull request is made to the main branch or
it's updated/reopened. Also, the workflow will run whenever there's a
push to the main branch.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
Updated the cache keys in both `eslint-front.yml` and `eslint-back.yml`
workflows. This change will help in differentiating the caches for
frontend and backend.

Signed-off-by: Nikolay Martyanov <[email protected]>
This commit adds server information to the api.yaml file. Both the local
development server and production server URLs have been specified.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
Updated the contact information: the name, url and email.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
Updated the title of the API from "Region Tracking API" to "Track Your
Regions API". Also added a description for the API.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
Added detailed descriptions to the API endpoints for clarity and better
understanding. This will help in effectively using the endpoints and
knowing what to expect from them.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
Assigned operationId for each endpoint for better identification of each
API operation. This will help in generating better API documentation and
client SDKs.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
Added tags to categorize operations. This will make it easier to
navigate and understand the structure of the API.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
Updated the linting command in package.json to fail on warning severity
level. This change will ensure stricter code quality checks.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
Expanded and revised the README.md under the API directory. The revised
document now includes more detailed guidelines, instructions for API
linting using Spectral, and contribution procedures.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
@OhmSpectator OhmSpectator linked an issue Jan 5, 2024 that may be closed by this pull request
5 tasks
Copy link

coderabbitai bot commented Jan 5, 2024

Walkthrough

The project has made several key changes to enhance the code quality and development workflow. Specifically, the GitHub Actions workflows for ESLint have been updated with more specific cache keys, and a new workflow for Spectral API checks has been introduced. Additionally, the API documentation and specification have undergone significant updates to improve clarity and include information on the API linting process.

Changes

File Path Change Summary
.github/workflows/eslint-back.yml
.github/workflows/eslint-front.yml
Updated cache keys to include specific prefixes for backend and frontend projects.
.github/workflows/spectral.yml Introduced new workflow for Spectral API checks.
api/.gitignore Excluded package-lock.json and node_modules from version control.
api/.spectral.yaml Added functionality to extend Spectral rules to the API directory.
api/README.md Underwent significant changes to improve clarity and expand contribution guidelines.
api/api.yaml Underwent significant updates to API details, including title, contact information, server URLs, tags, and path descriptions.

Assessment against linked issues

Objective Addressed Explanation
Set up Spectral API linter (#200)
Install Spectral CLI globally or as a dev dependency (#200)
Configure Spectral with ruleset (#200)
Address issues found by Spectral (#200) The summary does not specify if the current API issues were addressed using Spectral.
Integrate Spectral into development workflow (#200)
Document Spectral usage and configurations (#200)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit's AI:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

sweep-ai bot commented Jan 5, 2024

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Add jsdoc to all functions and file headers.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between dd50fcf and 5c36ecb.
Files ignored due to filter (1)
  • api/package.json
Files selected for processing (7)
  • .github/workflows/eslint-back.yml (1 hunks)
  • .github/workflows/eslint-front.yml (1 hunks)
  • .github/workflows/spectral.yml (1 hunks)
  • api/.gitignore (1 hunks)
  • api/.spectral.yaml (1 hunks)
  • api/README.md (1 hunks)
  • api/api.yaml (9 hunks)
Files skipped from review due to trivial changes (3)
  • .github/workflows/eslint-back.yml
  • .github/workflows/eslint-front.yml
  • api/.gitignore
Additional comments: 3
api/.spectral.yaml (1)
  • 1-1: The extension of the default Spectral rules for OAS is noted and aligns with the PR's objectives.
api/README.md (1)
  • 5-56: The updates to the README.md file provide clear and detailed guidelines, structure information, and instructions for API linting with Spectral. These changes enhance the documentation and align with the PR's objectives.
api/api.yaml (1)
  • 1-29: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [3-256]

The updates to the api.yaml file, including the new API title, contact information, server details, tags, and path descriptions, significantly improve the clarity and detail of the API specification. These changes are consistent with the OpenAPI Specification and the PR's objectives.

.github/workflows/spectral.yml Outdated Show resolved Hide resolved
@OhmSpectator OhmSpectator changed the title Feature/200 setup api linter Enhance API documentation and enforce linting standards Jan 5, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 5c36ecb and 8292b83.
Files selected for processing (3)
  • .github/workflows/eslint-back.yml (1 hunks)
  • .github/workflows/eslint-front.yml (1 hunks)
  • .github/workflows/spectral.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/spectral.yml
Additional comments: 4
.github/workflows/eslint-back.yml (2)
  • 47-47: The cache key has been correctly updated to include a "back-" prefix, ensuring differentiation of backend cache keys.

  • 49-49: Ensure that the restore-keys pattern is consistent with the new cache key prefix.

.github/workflows/eslint-front.yml (2)
  • 47-47: The cache key has been correctly updated to include a "front-" prefix, ensuring differentiation of frontend cache keys.

  • 49-49: Ensure that the restore-keys pattern is consistent with the new cache key prefix.

Changed the GitHub Action's cache key from package-lock.json to
package.json in eslint-front.yml, spectral.yml, and eslint-back.yml.
The lock file does not exist yet at this moment.

Issue: #200

Signed-off-by: Nikolay Martyanov <[email protected]>
@OhmSpectator OhmSpectator force-pushed the feature/200-setup-api-linter branch from 8292b83 to 7a5b510 Compare January 5, 2024 13:31
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 5c36ecb and 7a5b510.
Files selected for processing (3)
  • .github/workflows/eslint-back.yml (1 hunks)
  • .github/workflows/eslint-front.yml (1 hunks)
  • .github/workflows/spectral.yml (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/eslint-front.yml
  • .github/workflows/spectral.yml
Additional comments: 1
.github/workflows/eslint-back.yml (1)
  • 47-47: The update to the cache key with the "back-" prefix is a good practice to differentiate between backend and frontend node modules cache.

@OhmSpectator OhmSpectator merged commit 7363c95 into main Jan 5, 2024
14 checks passed
@OhmSpectator OhmSpectator deleted the feature/200-setup-api-linter branch January 5, 2024 13:33
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.

Setup API linter
1 participant