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

Referenced Parameters compiling to Object instead of Array #155

Open
bplainia opened this issue Mar 1, 2022 · 4 comments · May be fixed by #195
Open

Referenced Parameters compiling to Object instead of Array #155

bplainia opened this issue Mar 1, 2022 · 4 comments · May be fixed by #195
Labels
bug Something isn't working needs investigation Work is needed to figure out the root cause of the problem.

Comments

@bplainia
Copy link

bplainia commented Mar 1, 2022

I am having an issue with parameters being compiled as an object instead of an array. This is invalid OpenAPI.
I am using references heavily.
I have many different yaml files that are referenced by the primary spec so it is easy to maintain.
Each endpoint has parameters, which usually point to another file since they are used everywhere.
When a parameter reference points to something within the same file, the compiled parameter

Example Code (one of the referenced files) that does not work. It compiles to an object that has numbered keys.

'/v1/user':
  get:
    parameters:
      - $ref: 'parameters.yaml#/components/parameters/ApiVersion'
      - $ref: 'parameters.yaml#/components/parameters/Page'

Example Code (one of the referenced files) that does work. It compiles to an array.

'/v1/user':
  get:
    parameters:
      - $ref: 'parameters.yaml#/components/parameters/ApiVersion'
      - $ref: 'parameters.yaml#/components/parameters/Page'
      - $ref: '#/components/parameters/User'
@cebe
Copy link
Owner

cebe commented Mar 11, 2022

which part of the example code gets parsed as object instead of array?
Could you provide a complete test set of files that reproduce the issue?

@cebe cebe added the needs more info More information is needed to reproduce the issue. label Mar 11, 2022
@bplainia
Copy link
Author

@cebe
Please see https://github.com/bplainia/php-openapi-test and follow the instructions to build the compiled spec.

@cebe cebe added needs investigation Work is needed to figure out the root cause of the problem. bug Something isn't working and removed needs more info More information is needed to reproduce the issue. labels Apr 20, 2022
@Aribros
Copy link

Aribros commented Sep 14, 2023

@cebe Please see https://github.com/bplainia/php-openapi-test and follow the instructions to build the compiled spec.

I have investigated this but could not reproduce this. I also added a test to confirm all you have said but all passed.

@bplainia
Copy link
Author

bplainia commented Oct 6, 2023

It's been a while since I looked at this. I'm on a different project now and using swagger-php.
I updated my repo with the compiled yaml file. It still is doing it, though now both instances are generating objects. This is with a fresh clone and I ran composer api:build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigation Work is needed to figure out the root cause of the problem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants