php-openapi icon indicating copy to clipboard operation
php-openapi copied to clipboard

Referenced Parameters compiling to Object instead of Array

Open bplainia opened this issue 3 years ago • 4 comments

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'

bplainia avatar Mar 01 '22 20:03 bplainia

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 avatar Mar 11 '22 09:03 cebe

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

bplainia avatar Mar 11 '22 16:03 bplainia

@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.

Aribros avatar Sep 14 '23 10:09 Aribros

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

bplainia avatar Oct 06 '23 01:10 bplainia