hapi-swagger / hapi-swagger

A Swagger interface for hapi
https://hapi.dev/
MIT License
913 stars 420 forks source link

What is "Inline Model #"? #199

Closed chaeyk closed 8 years ago

chaeyk commented 8 years ago
    server.route({
        method: 'POST',
        path: '/auth/session',
        config: {
            tags: ['api'],
            response: {
                schema: Joi.object().label('schema').keys({
                    value: Joi.object().label('value').keys({
                        hello: Joi.number()
                    })
                })
            }
        },
        handler: function (req, reply) {
            reply(true);
        }
    });

that prints response model as

schema {
    value (Inline Model 1, optional)
}
Inline Model 1 {
    hello (number, optional)
}

I think that 'Inline Model 1' should be replaced with 'value', and there is no way to do that.

glennjones commented 8 years ago

Hi this took me a while to sort out. I had to rewrite elements of how models are created.

Swagger-UI use the phase "Inline Model" when it cannot find a title property for an object. It currently has a bug where sometimes child object are not named even when a title property is provided. I have a temporary work around I have hacked their Javascript to make this work and will file an issue on their repo.

You should now be able to label all your objects. You need to give each different structure its own unique name, but you can use a single structure as many times as you wish.

If you have any more problems please feel free to reopen the issue

jberger commented 8 years ago

Hi @glennjones, this is a terrible place to ask, but I see that you experienced issues with child objects in swagger-ui. I am also experiencing issues like this (not with hapi) and I was hoping you could share your patch and/or link to the issue you opened on their project? I would be very grateful!

jberger commented 8 years ago

I have seemed to be able to work around my issues given certain structure. Thanks all the same.