-
Notifications
You must be signed in to change notification settings - Fork 356
feat: Add JSON Schema definitions for AP2 mandate types #128
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
base: main
Are you sure you want to change the base?
feat: Add JSON Schema definitions for AP2 mandate types #128
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @ne275, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the interoperability of the AP2 protocol by introducing language-agnostic JSON Schema definitions for its core mandate types (Intent, Cart, and Payment). This change addresses previous limitations where only Python type definitions were available, thereby enabling broader adoption across non-Python implementations, facilitating Verifiable Credential support, and improving cross-language validation and type generation. The new schemas provide a standardized way to define and validate AP2 mandate objects, fostering a more robust and accessible ecosystem. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This is a great addition to the project! Providing JSON schemas significantly improves interoperability and makes it easier for developers using other languages to adopt AP2. The generation and validation scripts are excellent for ensuring the schemas stay in sync with the Pydantic models.
I've left a few suggestions to further improve the generated schemas and the documentation examples. Specifically, I've recommended:
- Fixing the Go example in the
schemas/README.mdto be runnable. - Improving the schema generation script to clean up descriptions and add
date-timeformats. - Making the validation script's dependency handling more user-friendly.
Overall, this is a very solid and valuable contribution. Well done!
- Add JSON Schema files for IntentMandate, CartMandate, and PaymentMandate - Create schema generation script using Pydantic's model_json_schema() - Add schema validation test script - Update README with JSON Schema documentation - Add comprehensive schemas/README.md with usage examples for Python, JavaScript, Go - Addresses issue requesting language-agnostic schema definitions for Verifiable Credentials support These schemas enable: - Validation of mandate objects in any programming language - Type generation for non-Python implementations - Verifiable Credential creation with proper schema references - IDE autocomplete and validation support
226c695 to
138fc74
Compare
…tResponse description
…xample - Add textwrap.dedent to clean up multi-line docstring descriptions - Add 'format: date-time' for timestamp fields (intent_expiry, cart_expiry, timestamp) - Fix Go example to include missing imports (fmt, log) - Fix Go example to properly handle validation errors (idiomatic error handling) - Regenerate schemas with improved formatting and date-time formats
- Fix MD030 linting errors by using single space after list markers - Change from '- ' to '- ' format for consistency
Description
This PR adds language-agnostic JSON Schema definitions for all AP2 mandate types, addressing the need for Verifiable Credential support in non-Python implementations.
Changes
schemas/intent-mandate.schema.jsonschemas/cart-mandate.schema.jsonschemas/payment-mandate.schema.jsonscripts/generate_schemas.py)model_json_schema()to ensure schemas stay in sync with Python types$schemaand$idfields for JSON Schema compliancescripts/validate_schemas.py)schemas/README.md)quicktypeProblem Solved
Previously, AP2 only provided Python type definitions (Pydantic models), which created barriers for:
Solution Benefits
These schemas enable:
Schema URLs
Schemas are publicly accessible at:
https://raw.githubusercontent.com/google-agentic-commerce/AP2/main/schemas/intent-mandate.schema.json
https://raw.githubusercontent.com/google-agentic-commerce/AP2/main/schemas/cart-mandate.schema.json
https://raw.githubusercontent.com/google-agentic-commerce/AP2/main/schemas/payment-mandate.schema.json
Testing
Checklist
CONTRIBUTINGGuideFixes #127