Skip to content

Incorrect validation of nested array items in OpenAPI spec #6943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pa3ng opened this issue May 2, 2025 · 1 comment
Open

Incorrect validation of nested array items in OpenAPI spec #6943

pa3ng opened this issue May 2, 2025 · 1 comment
Labels
feature/openapi-parsing The parsing logic for OpenAPI

Comments

@pa3ng
Copy link

pa3ng commented May 2, 2025

How urgent is this?

P2 - Medium (Would be helpful)

What's the issue?

Fern is incorrectly validating nested array items in our OpenAPI spec, specifically for the refunds array in the Transfer model.

Our OpenAPI spec defines:

  1. A Transfer model with top-level fields including transferID, source, destination, and a refunds array
  2. A separate CardAcquiringRefund model for items in the refunds array

Example TypeSpec:

model Transfer {
  transferID: string;
  source: TransferSource;
  destination: TransferDestination;
  // ... other fields ...
  refunds?: CardAcquiringRefund[];
}

model CardAcquiringRefund {
  refundID: string;
  createdOn: utcDateTime;
  updatedOn: utcDateTime;
  status: RefundStatus;
  amount: Amount;
  cardDetails?: RefundCardDetails;
}

Expected Behavior:

  • Fern should validate that each item in the refunds array matches the CardAcquiringRefund schema
  • Fern should not require transfer context fields (transferID, source, destination) on each refund item since these are already available at the transfer level

Current Behavior:
Fern is reporting validation errors:

[api]: transfers.yml -> service -> endpoints -> createTransfer -> examples[0] -> response
       transfers.yml
       Example is missing required property "response.body.refunds.0.transferID"
       Example is missing required property "response.body.refunds.0.source"
       Example is missing required property "response.body.refunds.0.destination"
       Unexpected property "refundID"
       Unexpected property "updatedOn"
       Unexpected property "cardDetails"

This suggests Fern is incorrectly expecting each refund item to include the 3 transfer fields, even though these fields are already available at the parent transfer level.

You can download our OpenAPI spec here. The example in our OpenAPI spec that we think this error occurs on is likely the following:

examples:
                Created synchronous transfer:
                  summary: Created synchronous transfer
                  value:
                    transferID: d835gf30-4b19-4850-a9b2-c0624c41ecb3
                    source:
                      paymentMethodID: 9506dbf6-4208-44c3-ad8a-e4431660e1f2
                      paymentMethodType: card-payment
                      account:
                        accountID: 7e4b26c2-b399-49ef-8390-50e1ea44d550
                        email: jules@julesjackson.com
                        displayName: Jules Jackson
                      card:
                        cardID: aefd5563-93c6-413c-875e-1bd0ebfc116d
                        fingerprint: 2f5d782ceef1c3bd31ed5...
                        brand: Visa
                        cardType: credit
                        lastFourCardNumber: '2000'
                        bin: '400020'
                        expiration:
                          month: '01'
                          year: '28'
                        holderName: Jules Jackson
                        billingAddress:
                          postalCode: '80301'
                        domesticPushToCard: standard
                        domesticPullFromCard: supported
                        cardVerification:
                          cvv: unavailable
                          addressLine1: unavailable
                          postalCode: unavailable
                          accountName:
                            firstName: unavailable
                            lastName: unavailable
                            middleName: unavailable
                            fullName: unavailable
                        issuer: Moov Visa Sandbox
                        issuerCountry: US
                        cardAccountUpdater: {}
                      cardDetails:
                        status: confirmed
                        dynamicDescriptor: WhlBdy *Yoga 11-12
                        confirmedOn: '2025-01-21T21:32:16.799681237Z'
                    destination:
                      paymentMethodID: 3f9969cf-a1f3-4d83-8ddc-229a506651cf
                      paymentMethodType: moov-wallet
                      account:
                        accountID: 34233b72-780c-4a0d-8b08-cbbe23k878f8
                        email: john@wholebodyfitness.io
                        displayName: Whole Body Fitness
                      wallet:
                        walletID: 744b2e78-8cc8-4a6a-af42-611e3b844503
                    status: pending
                    amount:
                      currency: USD
                      value: 32945
                    description: Transfer from card to wallet
                    createdOn: '2025-01-21T21:32:16Z'

But note that there is no refunds field set in this example, so we're not sure why the returned error suggests that this field is being set when it isn't.

Steps to reproduce errors:

  1. fern init --openapi ./path/to/openapi.yml (use our openapi.yaml spec linked above)
  2. fern generate

Impact:
This prevents us from using Fern to validate our OpenAPI spec, as it's incorrectly requiring fields that should not be present in the nested array items.

Environment:

  • OpenAPI version: 3.0.0
  • Fern version: 0.60.4
  • OS: macOS 15.4.1
  • Node: v23.11.0
@dannysheridan dannysheridan added the feature/openapi-parsing The parsing logic for OpenAPI label May 2, 2025
@pa3ng
Copy link
Author

pa3ng commented May 2, 2025

Update:

Instead of running fern generate, I was able to successfully generate the go models using fern generate --group go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/openapi-parsing The parsing logic for OpenAPI
Development

No branches or pull requests

2 participants