-
Notifications
You must be signed in to change notification settings - Fork 294
Add support for public attribute filtering in API docs #2659
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
Conversation
Update the specs.ts file to filter API methods based on the new 'public' attribute in x-appwrite metadata. Methods with public set to false will not be rendered in the documentation. This applies to both regular methods and additional methods defined in x-appwrite.methods array.
WalkthroughThis pull request makes two primary changes: (1) updates a devDependency reference in package.json to point to a new commit hash of the Appwrite repository, and (2) adds a Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/routes/docs/references/[version]/[platform]/[service]/specs.ts (3)
55-55: Consider makingpublicoptional for backwards compatibility.The type declares
publicas required, but the filtering logic at lines 269, 278, 284, 293, 302 uses optional chaining (?.public !== false), implying the attribute may be absent in older specs. For type accuracy and backwards compatibility with spec files that don't have this attribute:- public: boolean; + public?: boolean;
69-69: Consider makingpublicoptional here as well for consistency.If the
publicattribute inAppwriteOperationObject['x-appwrite']is made optional (as suggested above), this type should follow the same pattern for consistency.- public: boolean; + public?: boolean;
267-305: Consider extracting the repeated filtering pattern.The same filtering pattern is duplicated for each HTTP method. While functional, this could be consolidated:
const httpMethods = [ { key: 'get', method: OpenAPIV3.HttpMethods.GET }, { key: 'post', method: OpenAPIV3.HttpMethods.POST }, { key: 'put', method: OpenAPIV3.HttpMethods.PUT }, { key: 'patch', method: OpenAPIV3.HttpMethods.PATCH }, { key: 'delete', method: OpenAPIV3.HttpMethods.DELETE } ] as const; for (const { key, method } of httpMethods) { const op = methods?.[key]; if (op?.tags?.includes(service) && !hasAdditionalMethods(op, service)) { const operation = op as AppwriteOperationObject; if (operation['x-appwrite']?.public !== false) { yield { method, value: op, url }; } } }This reduces duplication and makes future additions of HTTP methods easier. However, the current explicit approach is also valid and more readable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
package.json(1 hunks)src/routes/docs/references/[version]/[platform]/[service]/specs.ts(5 hunks)
🔇 Additional comments (3)
src/routes/docs/references/[version]/[platform]/[service]/specs.ts (2)
213-216: LGTM!The filtering logic correctly skips methods where
publicis explicitlyfalse, allowing methods without the attribute or withpublic: trueto pass through.
228-233: LGTM!The
demoandpublicproperties are correctly propagated from the additional method to the yielded operation'sx-appwritemetadata.package.json (1)
35-35: Verify that commitaa12ef65693ea5fbbd954c0641f76422b440eb7ain the appwrite/appwrite repository contains the expectedpublicattribute changes in OpenAPI spec files.The dependency update references an external commit in the appwrite/appwrite repository. This cannot be independently verified from the website repository alone. Cross-reference the commit in appwrite/appwrite to confirm it includes the intended
publicattribute additions to the specification files.
Summary
publicattribute toAppwriteOperationObjectandAppwriteAdditionalMethodtype definitionsiterateAllMethodsfunction to filter out methods wherepublicis set tofalseprocessAdditionalMethodsfunction to skip additional methods wherepublicisfalse@appwrite.io/repoto include spec files with the newpublicattributeThis change allows API methods to be conditionally rendered in the documentation based on the
publicattribute in the OpenAPI spec'sx-appwritemetadata.Test plan
public: trueare displayed in the documentationpublic: falseare not displayed in the documentationx-appwrite.methodsbefore and after:


Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.