Skip to content

Commit

Permalink
[SM-1402] Automatic PHP schema generation (#1036)
Browse files Browse the repository at this point in the history
## 🎟️ Tracking

https://bitwarden.atlassian.net/browse/SM-1402
(Not part of this ticket, but agreed with @tangowithfoxtrot that it
would make sense to do so)

## 📔 Objective

Automatic PHP Schema generation using quicktype.
The schema is not compatible with previously generated Swaggest based
schema - PHP code changes are required (does not affect the usage,
`README.md` and `example.php` works as before)
Notable code changes:
- Schema class fields are private, no setters or getters. Can only init
the classes via constructor. (Could enable getters in schema generation,
but the quicktype does not respond well with nested arrays that are part
of schema, as a result PHP generated schema file does not compile)
- Schema class constructors are initialized with named arguments, which
is more readable than `new Command(null, null, null, null, null,
$secrets_command, null, null)
- Uses PHP native json serialization, but SDK does not react well to
null fields, so adjusted the code to remove it just before JSON
serialization.
- Separated `AuthClient` into separate file
- Imports with `uses`

## ⏰ Reminders before review

- Contributor guidelines followed
- All formatters and local linters executed and passed
- Written new unit and / or integration tests where applicable
- Protected functional changes with optionality (feature flags)
- Used internationalization (i18n) for all UI strings
- CI builds passed
- Communicated to DevOps any deployment requirements
- Updated any necessary documentation (Confluence, contributing docs) or
informed the documentation
  team

## 🦮 Reviewer guidelines

<!-- Suggested interactions but feel free to use (or not) as you desire!
-->

- 👍 (`:+1:`) or similar for great changes
- 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info
- ❓ (`:question:`) for questions
- 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry
that's not quite a confirmed
  issue and could potentially benefit from discussion
- 🎨 (`:art:`) for suggestions / improvements
- ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or
concerns needing attention
- 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or
indications of technical debt
- ⛏ (`:pick:`) for minor or nitpick changes
  • Loading branch information
mzieniukbw authored Sep 18, 2024
1 parent 64e984c commit 49b5023
Show file tree
Hide file tree
Showing 29 changed files with 329 additions and 1,335 deletions.
2 changes: 2 additions & 0 deletions languages/php/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
vendor
src/lib/
src/Schemas/
4 changes: 2 additions & 2 deletions languages/php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"version": "0.1.0",
"require": {
"php": "^8.0",
"swaggest/json-schema": "^0.12.42",
"ext-ffi": "*"
},
"autoload": {
"psr-4": {
"Bitwarden\\Sdk\\": "src/"
}
},
"files": ["src/Schemas/Schemas.php"]
},
"authors": [
{
Expand Down
230 changes: 2 additions & 228 deletions languages/php/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 49b5023

Please sign in to comment.