-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
--array-length
with minItems: 1
generates empty array
#2048
Comments
I've been poking at this implementation in order to fix this bug and came across what I think is unexpected behavior, making it impossible to generate heterogeneous array types. Given this schema, here are the generated types. components:
schemas:
HeterogeneousArray:
type: array
items:
- type: number
- type: string // Result type is [number, string], not [number | string]()
interface components = {
schemas: {
HeterogeneousArray: [number, string];
}
}; Forgive me if I missed some discussion around this, but I thought for items in fixed positions it would be necessary to use the Looking at the spec, # Incorrect
items:
- type: string
- type: integer
# Incorrect as well
items:
type:
- string
- integer Is this array-of-item-types a custom behavior only supported by openapi-typescript? |
* Simplify minItems / maxItems tuple generation Closes #2048 * fixup! Simplify minItems / maxItems tuple generation Account for immutable: true * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation * fixup! Simplify minItems / maxItems tuple generation
Yeah I’m seeing the same thing with This looks like a bug to me; would love a PR to fix this 🙏
@duncanbeevers this is one of those “rabbit hole” things where because OpenAPI 3.x supports JSON Schema, and the 2020-12 version supports this, by extension it’s technically allowed. It’s strange, but there is some evidence to suggest this is valid, believe it or not (also #1011 was one of the issues that led to the deeper rewrite of 7.x) |
Okay. I'll re-add support for items-as-array with the Is there already a mechanism in place for deprecations? |
To be honest I’ve never thought of that use of feature flags for this library. We’ve used them for completely alternate behaviors that are preference, not necessarily breaking changes. But I do know some libraries do that, especially if something is extremely disruptive and needs feedback and testing. That may also be easier to maintain than a separate branch/release tag that desyncs with 7.x, where it fixes some bugs but is otherwise behind all the patches and features. Will run this idea by the other maintainers for feedback |
Description
--array-length
withminItems: 1
generates empty array.Tested with v7.4.4 and v7.1.2.
Reproduction
Copy the example here: https://openapi-ts.dev/cli#arraylength
Expected result
Actual result
Checklist
npx @redocly/cli@latest lint
)The text was updated successfully, but these errors were encountered: