hapi-swagger icon indicating copy to clipboard operation
hapi-swagger copied to clipboard

Ref

Open indreek opened this issue 8 years ago • 0 comments

Context

  • *hapi-swgger 7.4.0 *:

What are you trying to achieve or the steps to reproduce ?

  {
    path: '/bar/arrays',
    method: 'POST',
    config: {
      handler: function () { },
      tags: ['api'],
      response: {
        schema: Joi.array()
          .items(
            Joi.array()
              .items(
                Joi.object({ bar: Joi.string() })
                  .label('FooArrObj')
              )
              .label('FooArr')
          )
          .label('FooArrParent')
      },
      validate: {
        payload: Joi.array()
          .items(
            Joi.array()
              .items(
                Joi.object({ bar: Joi.string() })
                  .label('FooArrObj')
              )
              .label('FooArr')
          )
          .label('FooArrParent')

      }
    }
  }

What result did you get?

swagger.json generates:

paths: {
		/bar/arrays: {
			post: {
				operationId: "postBarArrays",
				parameters: [{ in: "body",
					name: "body",
					schema: {
						type: "array",
						$ref: "#/definitions/FooArrParent"
					}
				}],
				tags: [
					"bar"
				],
				responses: {
					200: {
						schema: {
							$ref: "#/definitions/FooArrParent",
							type: "array"
						},
						description: "Successful"
					}
				}
			}
		}
	},
	definitions: {
		FooArrObj: {
			type: "object",
			properties: {
				bar: {
					type: "string"
				}
			}
		},
		FooArr: {
			type: "array",
			items: {
				$ref: "#/definitions/FooArrObj",
				type: "object"
			}
		},
		FooArrParent: {
			type: "array",
			items: {
				$ref: "#/definitions/FooArr",
				type: "array"
			}
		}
	}

What did you expect ?

If it references, why is type in items block? Am i doing something wrong or should it be there?

Indre

indreek avatar Nov 02 '16 13:11 indreek