Skip to content

fix(orders): tighten shipping address, line, and item schema constraints#121

Open
leofischer wants to merge 2 commits into
release/v2.3.0from
fix/shipping-address-validation-schema
Open

fix(orders): tighten shipping address, line, and item schema constraints#121
leofischer wants to merge 2 commits into
release/v2.3.0from
fix/shipping-address-validation-schema

Conversation

@leofischer

@leofischer leofischer commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Aligns the OpenAPI schemas for order shipping address, shipping line, and line item with the validations actually enforced by payments-api's v200 param sanitizers. These fields were documented as free-form strings with no required markers or length limits, despite the API rejecting them.

Targets release/v2.3.0.

Changes

Consolidation (shared address component)

  • New schemas/customers/shipping_contact_address.yml; the create and update shipping-contact schemas now $ref it instead of each carrying a duplicated inline address block. The shipping_contact used by orders (order_request, order_update_request, split_order_request) already routes through these schemas, so the order shipping address is covered by the same definition.

Required markers (matching ShippingContacts::Validator#validate_on_create)

  • address.street1, address.postal_code, address.country are now required on create; the update path leaves them optional.

Format / descriptions

  • Documented the MX rule (country == MX -> 5-digit postal code) on postal_code.
  • Added per-field descriptions to the address fields (previously only country had one).

Length constraints (matching StringValidator)
The sanitizer uses strict comparisons: length >= less_than -> too_long, length <= greater_than -> too_short. So a 250-char value is rejected; the maximum accepted length is 249, and minLength = greater_than + 1.

  • maxLength: 249 on all sanitizer-bounded strings: address street1/street2/city/state/country; shipping line carrier/tracking_number/method; line-item name/description/brand/sku and tags[] items (create + update).
  • minLength: street1/country 2; carrier/tracking_number/method/name/description 3; brand 2; sku 1; tags[] items 2; tags minItems: 1.
  • postal_code keeps maxLength: 250: the sanitizer only type-checks it, so its only length cap is the model-level validates :zip, length: { maximum: 250 } (inclusive).

Build

  • Regenerated _build/api.yaml via make merge; all $refs resolve and the create-path required markers survive bundling.

Notes

  • The 249 vs 250 split is intentional and correct: 249 reflects the sanitizer's exclusive < 250; postal_code's 250 reflects the inclusive model bound.
  • No Jira ticket was provided; consistent with other doc-fix PRs in this repo.

🤖 Generated with Claude Code

Align the OpenAPI schemas with the validations enforced by payments-api's
v200 param sanitizers, which were previously under-documented.

- Extract the shipping-contact address into a shared
  schemas/customers/shipping_contact_address.yml and reference it from the
  create and update shipping-contact schemas, removing the duplicated inline
  address blocks.
- Mark street1, postal_code, and country as required on the create path
  (matching ShippingContacts::Validator#validate_on_create); the update path
  keeps them optional.
- Document the MX 5-digit postal code rule and add field descriptions.
- Add maxLength: 250 to address fields, shipping line carrier/tracking_number/
  method, and line-item name/brand/sku and tag items.
- Regenerate _build/api.yaml.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@atlantis-conekta

Copy link
Copy Markdown
Error: This repo is not allowlisted for Atlantis.

Align the OpenAPI schemas with the validations enforced by payments-api's
v200 param sanitizers, which were previously under-documented.

- Extract the shipping-contact address into a shared
  schemas/customers/shipping_contact_address.yml and reference it from the
  create and update shipping-contact schemas, removing the duplicated inline
  address blocks.
- Mark street1, postal_code, and country as required on the create path
  (matching ShippingContacts::Validator#validate_on_create); the update path
  keeps them optional.
- Document the MX 5-digit postal code rule and add field descriptions.
- Add min/max length constraints matching StringValidator (strict bounds:
  less_than/greater_than). String fields cap at maxLength 249 (the sanitizer
  rejects length >= 250); minLength derives from greater_than + 1. postal_code
  keeps maxLength 250, its only cap being the model-level zip validation.
  Applies to address fields, shipping line carrier/tracking_number/method, and
  line-item name/description/brand/sku/tags (create and update).
- Regenerate _build/api.yaml.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant