Document and test expanded Fleet resource APIs - #59
Open
roncodes wants to merge 1 commit into
Open
Conversation
Brings the Fleetbase API collection in line with the expanded public Fleet, Vehicle and Driver contracts, and adds request-specific response assertions so a collection run proves the behaviour rather than only that a 2xx came back. Fleets - Create/Update accept name, color, task, status and the service_area, zone, vendor and parent_fleet relationships as public IDs. - New "Create a Subfleet" request covering the parent_fleet hierarchy, with 422 self-parent and 404 cross-company examples. - Four new membership requests, plus a repeat of each, covering assignment, idempotent reassignment, removal and no-op re-removal for both vehicles and drivers, with a single stable response shape. - Relationships documented as public IDs, with the nested-object shape kept for ?with= requests. - Query parameters documented: name, public_id, status, task, parent_fleet, parents_only, vendor, service_area, zone. Vehicles - Every safe business field the vehicle record holds is now documented on create and update. - The status enum is reconciled with the implementation: nineteen values were accepted while three were documented. - Query parameters documented, including internal_id, which an importer keys on. Drivers - email and phone documented as optional, with a dedicated "Create an Operational Driver" request for a record with neither. - Identity, operational, structured and orchestrator fields documented. - password removed from the update contract, which the API does not accept. - Query parameters documented, including internal_id and licence number. The Vehicles and Drivers folders delete their own resources before the Fleets folder runs, so the membership requests create and clean up a vehicle and a driver of their own rather than reaching for ids that no longer resolve. Validation: npm run postman:lint — 0 errors, 0 warnings across all five collections. Live collection execution is pending deployment of the Fleet-Ops branch. No credentials, real API keys or customer data are included.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings the Fleetbase API collection in line with the expanded public Fleet,
Vehicle and Driver contracts, and adds request-specific response assertions so a
collection run proves the documented behaviour rather than only that a 2xx came
back.
Implementation PR: fleetbase/fleetops#311 — this PR documents and
tests that one.
Type of Change
Implementation Notes
Fleets
Request/response contracts:
name,color,task,status, and theservice_area,zone,vendorandparent_fleetrelationships. Relationships are public IDs(
service_area_...,zone_...,vendor_...,fleet_...) resolved insidethe authenticated organization; a cross-company ID is answered exactly as a
missing one is.
nullclears an assignment.statusis documented as a short string rather than a closed enum: theconsole offers
active/disabled/decommissioned, but the column is notconstrained and existing integrations write other values.
New requests:
fleet_idandparent_fleet_idparent_fleethierarchy; seedssubfleet_idassigned: trueassigned: trueassigned: falseassigned: falseAssignments run before removals, memberships are removed before the resources
are deleted, and the subfleet is deleted before its parent.
Why the membership requests create their own vehicle and driver. The
Vehicles folder (order 6000) and the Drivers folder (7000) both delete their own
resource before the Fleets folder (9000) runs, so
{{vehicle_id}}and{{driver_id}}no longer resolve by then. Rather than let the membershipassertions fail on a stale id, the folder creates — and cleans up — a vehicle
and a driver of its own.
{{vendor_id}}and{{service_area_id}}are stillreused, since those folders' resources are created earlier and are still live.
New collection variables, all narrowly named:
parent_fleet_id,subfleet_id,fleet_vehicle_id,fleet_driver_id,operational_driver_id.Vehicles
field the vehicle record holds: identity and description, odometer and
measurement, body, capacity and dimensions, lifecycle and financing,
regulatory and engine specifications, structured
specs/details/meta,orchestrator constraints, and the
vendor,driver,categoryandwarrantyrelationships.documented three values (
operational,maintenance,decommissioned) whilethe API accepts nineteen. All nineteen are now listed, with a note that
activeis stored asavailable.internal_id— the lookup an importerkeys on before deciding whether to create — plus
plate_number,vin,public_id,vendor,driverandfleet.Drivers
emailandphoneare documented as optional, validated and unique whensupplied.
Delete an Operational Driver to clean it up. Its description states
plainly that such a driver cannot sign in to Navigator until credentials are
supplied.
internal_id,drivers_license_number,license_expiry,photo), operational (country,currency,city,online,current_status,status, location and telemetry), structuredmetaandorchestrator fields are all documented.
passwordremoved from the update contract — the API does not accept itthere, and the dedicated password endpoints are referenced instead.
internal_id,drivers_license_number,phone,vehicle,vendorandfleet.Response assertions
Every new and updated request carries its own
afterResponseblock rather thanrelying on the collection-wide "2xx and JSON" test. Between them they assert:
200/201only where the contractgenuinely permits either.
array. No
{data: ...}wrapper is assumed — none of these endpoints uses one.including the ones that used to be silently discarded: the vehicle odometer,
and driver
metaandinternal_id.parent_fleetresolves to the parent's public ID, and a fleet is never itsown parent.
service_area,vendorandzoneresolve to public IDs.assignedistrueafter an assignment andfalseafter a removal, a repeated assignmentstays successful and produces no duplicate logical membership, and a repeated
removal is a successful no-op.
onlineinparticular, which a partial update used to reset.
uuid,company_uuid,*_uuid,auth_token,signup_token_used,_key) appears anywhere the public contract shouldexpose a public ID.
Error examples were added for validation and cross-company behaviour:
422for a self-parented fleet and for invalid vehicle input,404for across-company
parent_fleet,vendor, or membership resource, and422for amalformed or duplicate driver contact detail.
Object definitions and examples
Fleets/,Vehicles/andDrivers/.resources/object.yamlwere updated tomatch the responses the API now returns, and the
<string>placeholder exampleswere replaced with realistic bodies. The Drivers examples previously documented
signup_token_used,phone_numberandphone_country_code, none of which theresource returns.
The Fleets folder description carries the membership endpoint contract and the
shared response shape.
Validation
$ npm run postman:lint Validated 5 Postman Native Git collections and 3 environments. Linting Fleetbase API... No issues found. Scanned: 212 | Errors: 0 | Warnings: 0 Linting Fleetbase Core API... No issues found. Scanned: 24 | Errors: 0 | Warnings: 0 Linting Fleetbase Integrated Vendor Flow... No issues found. Scanned: 7 | Errors: 0 | Warnings: 0 Linting Fleetbase Ledger API... No issues found. Scanned: 8 | Errors: 0 | Warnings: 0 Linting Fleetbase Storefront API... No issues found. Scanned: 62 | Errors: 0 | Warnings: 0This ran both
scripts/validate-collections.jsand the Postman Native Gitschema lint (Postman CLI 1.46.0 was available).
Live collection run: pending.
npm run postman:run:fleetbasehas notbeen executed — no Fleetbase deployment carrying the Fleet-Ops branch was
available, and the new membership endpoints and expanded fields do not exist on
any currently deployed build, so a run would fail for the absence of the
implementation rather than for anything in this PR. The response assertions
above are therefore not claimed to have passed live. Once
fleetbase/fleetops#311 is deployed to a test environment:
Nothing here was run against production.
Documentation Impact
API Reference Impact
fleetbase/postmanAPI reference notes: if the
fleetbase.ioAPI reference is generated from thisrepository, it needs regeneration once this PR and
fleetbase/fleetops#311 land. No change was made to
fleetbase/fleetbase.io.Risk
The changes are specification and test only. The one behavioural risk in a
contract run is ordering: the Fleets folder now creates two resources of its own
and deletes them at the end of the folder, and the driver-authentication and
password requests are untouched —
driver_identity,driver_passwordanddriver_phoneare still not written by any request here.Confirmation
No credentials, real API keys, tokens, or customer data were committed. All
identifiers in examples are illustrative.