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

feat: Implement JSON Schema Validation for User API Responses #17731

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AmpasTheodoros
Copy link

Problem Solved: The Cal.com API v2 was exhibiting inconsistent behavior with response bodies changing unpredictably. This inconsistency was causing errors in applications relying on the API, leading to disruptions in functionality and user experience. The issue stemmed from a lack of a fixed and documented schema for API responses

Solution Implemented:

  • Defined a JSON schema to establish a consistent structure for user-related API responses
  • Integrated the Ajv library into the UsersService to validate responses against the schema
  • Added validation logic in the getByUsernames method to ensure each user response adheres to the schema, throwing an error if it does not

Trade-offs or Limitations:

  • The current implementation focuses on user-related responses. Extending schema validation to other modules may be necessary for comprehensive consistency
  • Future changes to the API response structure will require updates to the schema and potentially the validation logic
  • A versioning strategy and deprecation policy should be considered to manage future changes and maintain backward compatibility

Problem Solved: The Cal.com API v2 was exhibiting inconsistent behavior with response bodies changing unpredictably. This inconsistency was causing errors in applications relying on the API, leading to disruptions in functionality and user experience. The issue stemmed from a lack of a fixed and documented schema for API responses.

Solution Implemented:

Defined a JSON schema to establish a consistent structure for user-related API responses.
Integrated the Ajv library into the UsersService to validate responses against the schema.
Added validation logic in the getByUsernames method to ensure each user response adheres to the schema, throwing an error if it does not.
Trade-offs or Limitations:

The current implementation focuses on user-related responses. Extending schema validation to other modules may be necessary for comprehensive consistency.
Future changes to the API response structure will require updates to the schema and potentially the validation logic.
A versioning strategy and deprecation policy should be considered to manage future changes and maintain backward compatibility.
Copy link

vercel bot commented Nov 19, 2024

@AmpasTheodoros is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Nov 19, 2024

CLA assistant check
All committers have signed the CLA.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Nov 19, 2024
@graphite-app graphite-app bot requested a review from a team November 19, 2024 02:42
Copy link
Contributor

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Implement JSON Schema Validation for User API Responses". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@dosubot dosubot bot added the api area: API, enterprise API, access token, OAuth label Nov 19, 2024
Copy link

graphite-app bot commented Nov 19, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (11/19/24)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (11/19/24)

1 label was added to this PR based on Keith Williams's automation.

"Add ready-for-e2e label" took an action on this PR • (11/21/24)

1 label was added to this PR based on Keith Williams's automation.

@Praashh
Copy link
Contributor

Praashh commented Nov 19, 2024

Hey @AmpasTheodoros please sign CLA

@Praashh Praashh changed the title Implement JSON Schema Validation for User API Responses feat: Implement JSON Schema Validation for User API Responses Nov 19, 2024
@AmpasTheodoros
Copy link
Author

Hey @Praashh thanks for fixing my title I just signed CLA

@keithwillcode keithwillcode requested review from a team and removed request for a team November 19, 2024 13:24
@keithwillcode keithwillcode added this to the v4.8 milestone Nov 19, 2024
Copy link
Contributor

@Praashh Praashh left a comment

Choose a reason for hiding this comment

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

LGTM!!

Copy link
Contributor

E2E results are ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api area: API, enterprise API, access token, OAuth community Created by Linear-GitHub Sync ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants