Skip to content
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

Producing an unknown[] type for an array field with items set to a type #726

Closed
lmossman opened this issue Jan 10, 2023 · 4 comments
Closed
Labels
invalid This doesn't seem right

Comments

@lmossman
Copy link

lmossman commented Jan 10, 2023

What are the steps to reproduce this issue?

  1. Clone my orval-example repo: https://github.com/lmossman/orval-example
  2. Run npm install then npm run orval
  3. See that the Client.ts file produced has an unknown[] type, which is unexpected: https://github.com/lmossman/orval-example/blob/c460c310267f03311e00dda5a2f1394c2db4a839/src/client/Client.ts#L25

What happens?

The fields field has its type set to unknown[]

What were you expecting to happen?

The type of fields should be AddedFieldDefinition[] instead of unknown[]

Any logs, error output, etc?

It doesn't seem related, but this is printed out for the repro instructions I listed above. These same logs aren't printed out for my production repo though, so my guess is these are coming from me trying to just pull a sample of the schema out for the example

⚠️  SyntaxError: Swagger schema validation failed.
  #/paths/~1transformations/get/responses/200/content/application~1json/schema must NOT have additional properties
  #/paths/~1transformations/get/responses/200/content/application~1json/schema must NOT have additional properties
  #/paths/~1transformations/get/responses/200/content/application~1json/schema must NOT have additional properties
  #/paths/~1transformations/get/responses/200/content/application~1json/schema/properties/add_fields/properties/fields/items must be object
  #/paths/~1transformations/get/responses/200/content/application~1json/schema/properties/add_fields/properties/fields/items must be object
  #/paths/~1transformations/get/responses/200/content/application~1json/schema/properties/add_fields/properties/fields/items must match exactly one schema in oneOf
  #/paths/~1transformations/get/responses/200/content/application~1json/schema/properties/add_fields/properties/fields must have required property '$ref'
  #/paths/~1transformations/get/responses/200/content/application~1json/schema/properties/add_fields/properties/fields must match exactly one schema in oneOf
  #/paths/~1transformations/get/responses/200/content/application~1json/schema/properties/add_fields must have required property '$ref'
  #/paths/~1transformations/get/responses/200/content/application~1json/schema/properties/add_fields must match exactly one schema in oneOf
  #/paths/~1transformations/get/responses/200/content/application~1json/schema must have required property '$ref'
  #/paths/~1transformations/get/responses/200/content/application~1json/schema must match exactly one schema in oneOf
  #/paths/~1transformations/get/responses/200 must have required property '$ref'
  #/paths/~1transformations/get/responses/200 must match exactly one schema in oneOf

Any other comments?

My guess is that orval has trouble with an array field when items is set to a $ref - it seems like it loses the type when that happens and defaults to setting the type of the array to unknown

What versions are you using?

Operating System: macOS 12.5
Package Version: 6.11.0
Browser Version: Chrome 108.0.5359.124

@lmossman lmossman changed the title Orval is unexpectedly producing an unknown[] type for an array field with items set to a $ref Orval is unexpectedly producing an unknown[] type for an array field with items set to a type Jan 13, 2023
@lmossman
Copy link
Author

@anymaniax I just noticed that this is actually also happening for a json schema array whose items field is not set to a ref, e.g.

    properties:
      array_field:
        type: array
        items:
          - type: string

causes orval to produce a array_field: unknown[] instead of array_field: string[]

@arthurfiorette
Copy link
Contributor

same here

@melloware melloware added the bug Something isn't working label Nov 10, 2023
@melloware
Copy link
Collaborator

Can you confirm this is still happening with 6.20.0 ?

@melloware melloware assigned melloware and unassigned melloware Nov 15, 2023
@melloware melloware changed the title Orval is unexpectedly producing an unknown[] type for an array field with items set to a type Producing an unknown[] type for an array field with items set to a type Nov 15, 2023
@arthurfiorette
Copy link
Contributor

It's not happening for us anymore... However our schema has changed a lot since and as no reproduction repository was made, you can close this issue until further notice.

@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2024
@melloware melloware added invalid This doesn't seem right and removed bug Something isn't working invalid This doesn't seem right labels Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants