0

I'm using Swagger and I want to get with annotations an API doc like that :

"myproperty":{
    "nullable": true,
    "$ref": "#/components/schemas/MyProperty"
}

So I tried with :

  /**
   * @var MyProperty|null
   *
   * @OA\Schema(ref=@Model(type=MyProperty::class), nullable=true)
   */
  private $myproperty;

But when I generate my doc.json, I have :

"myproperty": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/Meta"
              }
            ]
          }

Having "$ref" in an array is an issue for me. How could I change that ?

Menryck
  • 149
  • 1
  • 9
  • Is the issue that the `$ref` points to the `Meta` schema instead of the `MyProperty` schema? Or do you mean some other issue? – Helen Feb 18 '22 at 15:06
  • Mistake in my copy-paste. It's myproperty. Actually, I don't want to have an "allOf". I saw I could change it in "oneOf" or "manyOf" but it's the same issue : with "nullable: true" it's inside an array. – Menryck Feb 18 '22 at 15:10
  • The use of `allOf` is correct, it's the proper way to add keywords to a `$ref` in OAS 3.0.x and 2.0. See [this Q&A](https://stackoverflow.com/q/33629750/113116) for the explanation. – Helen Feb 18 '22 at 17:36

0 Answers0