add-nullable-field

Patch NULLABLE_FIELDS in scripts/regenerate_client.py to make schema fields Optional.

Updated Jul 18, 2025
One-click install
npx skills add https://github.com/dougborg/stocktrim-openapi-client --skill add-nullable-field
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-nullable-field
Source: https://github.com/dougborg/stocktrim-openapi-client/tree/main/.claude/skills/add-nullable-field
Command: npx skills add https://github.com/dougborg/stocktrim-openapi-client --skill add-nullable-field

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents generated client crashes when the StockTrim API returns null for fields the OpenAPI spec (or generator settings) marked as required.

Core Features & Use Cases

  • Schema field nullability fixes: Adds the specific schema field to the regeneration script’s NULLABLE_FIELDS so the generated model becomes Optional.
  • Safe, reproducible regeneration: Re-runs the client regeneration from the spec to avoid manual edits to generated/ code.
  • Verification-first workflow: Runs the project checks after regeneration and inspects the diff to absorb any spec drift.

Quick Start

Ask the AI to regenerate the client with a given schema and field added to NULLABLE_FIELDS after you share the exact error message indicating which field was returned as null.

Frequently Asked Questions about add-nullable-field

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix TypeErrors in a generated OpenAPI Python client when the API returns null for required fields?

Fix TypeErrors in a generated OpenAPI Python client by patching the regeneration script's NULLABLE_FIELDS list to treat the mismatched schema fields as Optional, then regenerating the client to prevent runtime crashes.

Why does my generated Python client crash when the API response includes null values not defined in the OpenAPI spec?

Generated Python clients crash on unexpected nulls due to API drift between the OpenAPI spec and real responses, requiring schema field nullability fixes to safely update generated models to Optional.

What is the best way to handle API drift in OpenAPI code generation without manually editing generated files?

Handle API drift safely by updating the NULLABLE_FIELDS configuration in the regeneration script and re-running the client generation command, avoiding manual edits to generated code directories.

How to add nullable fields to an OpenAPI generated client using a regeneration script?

Add nullable fields by patching the regeneration script with the target schema field names, executing the provided regeneration command, and running project checks to verify the generated Optional types.

Do I need to run project checks after regenerating an OpenAPI client with new nullable fields?

Yes, run project checks after regenerating the OpenAPI client to inspect the diff, verify the Optional type integration, and absorb any remaining spec drift before deploying the updated models.

When should I update NULLABLE_FIELDS in my OpenAPI client regeneration workflow?

Update NULLABLE_FIELDS when you observe null evidence in real API responses for spec-required fields, causing TypeErrors in the generated Python client that necessitate making the schema fields Optional.