Skip to content

type: string schemas use properties: to document enum values, breaking code generation #233

Description

@declaresub

In 2020-09-14.yml (current version 2020-09-14_1.688.6), several schemas are declared as type: string but also include a properties: block listing the intended enum values as object-property names with descriptions. Per the OpenAPI 3.0 / JSON Schema spec, properties: is only valid for type: object; on a type: string schema it is meaningless at best.

Code generators that walk properties: interpret these fields as object schemas instead of constrained strings, producing class models that cannot validate the actual API payloads.

Example — LinkSessionExitMetadata.status:

LinkSessionExitMetadata:
type: object
properties:
status:
type: string
description: The point at which the user exited the Link flow. One of the following values.
properties:
requires_questions:
description: User prompted to answer security questions
requires_selections:
description: User prompted to answer multiple choice question(s)
# ...
A real Link exit webhook delivers status: "requires_credentials" (a string). Under datamodel-code-generator, the property above is generated as a Pydantic Status BaseModel with one Any | None field per enum-value name, which will never validate against a string payload.

Affected schemas in the current spec:

LinkSessionExitMetadata.status
UnofficialCurrencyCodeList
DepositoryAccount
CreditAccount
LoanAccount
InvestmentAccountSubtypeStandalone
PayrollAccount
StandaloneInvestmentTransactionBuyType
StandaloneInvestmentTransactionCashType
StandaloneInvestmentTransactionFeeType
StandaloneInvestmentTransactionSellType
StandaloneInvestmentTransactionTransferType
Suggested fix:

Replace each properties: block on a type: string schema with an enum: list, e.g.

status:
type: string
description: The point at which the user exited the Link flow.
enum:
- requires_questions
- requires_selections
- requires_code
- choose_device
- requires_credentials
- requires_account_selection
- requires_oauth
- institution_not_found
- institution_not_supported
If per-value descriptions need to be preserved for documentation, OpenAPI supports the x-enum-descriptions (or x-enum-varnames) vendor extension, which most generators understand and emit as comments.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions