Skip to content

Audit the v2 client library + generation script; clean up openapi.json upstream #184

Description

@amarcozzi

Part of #176.

The v2 client library (fastfuels_sdk/v2/client_library/) is generated from the API's openapi.json by fastfuels_sdk/v2/generate_client.sh (openapi-python-client, pinned 0.29.0). Several rough edges in the generated client trace back to the spec, not our wrapper — and the right fix for most of them is to clean up openapi.json in the FastFuels-API-v2 repo so the generator produces a better client with no post-generation patching.

Goal

Comb through the generated client library and generate_client.sh for warnings and bad practices, and produce a list of API-side openapi.json fixes that would yield the best possible generated client (ideally one generated with --meta defaults and zero patch steps).

Known items to fold in

  • Duplicate Feature schema title. The spec titles two schemas Feature (the FastFuels feature resource and geojson-pydantic's GeoJSON Feature). openapi-python-client names classes from titles and refuses the collision, so generate_client.sh patches the GeoJSON one to GeoJsonFeature before generating. Fix: re-title the model in FastFuels-API-v2 so the spec has no collision, and drop the patch step. (was the original Implement v2 API support #176 re-title checklist item)
  • No servers entry. The spec advertises no servers, so the generated client embeds no URL and generate_client.sh records the deployment URL into client_library/base_url.py, which api.py imports as the default. Adding a servers entry upstream would let the generated client carry the canonical URL natively and let us drop the base_url.py shim. (Connects to the stable-domain decision on Implement v2 API support #176.)
  • String-detail 422s. The spec types error detail as a list of validation errors, but the API sometimes returns a bare string, which crashes the stock generated parser — exceptions.py carries tolerant-parsing code to compensate. Fix the response typing (or the API's actual responses) so the generated parser is correct.
  • anyOf explosion. ~38% of schemas use anyOf (FastAPI/pydantic emit it for every Optional; geojson-pydantic adds geometry unions). Review whether any of it can be tightened so the generated models are cleaner.

Tasks

  • Run generate_client.sh and capture every generator warning; triage each to a spec fix or an accepted wart
  • Audit the generated models/endpoints for bad practices (naming, missing descriptions, untyped responses, the anyOf cases above)
  • File the resulting openapi.json fixes against FastFuels-API-v2 (cross-reference existing ones, e.g. FastFuels-API-v2#335)
  • Once the spec is clean, simplify generate_client.sh (drop the title patch; pick up servers) and regenerate

Metadata

Metadata

Assignees

No one assigned

    Labels

    v2FastFuels v2 API / SDK work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions