Forum Discussion

HenrikHL's avatar
HenrikHL
Frequent Contributor
2 years ago

oneOf always rendered in the bottom of an object

Hi,

I have been fighting a little with this and I can simply not get the following to render in "correct order":

Whenever I declare something using the oneOf - it always renders in the bottom of the object (in the image above called object1). I would like the oneOf to be rendered above the attribute henrik.

Is this possible? And if not - why not?

  • HenrikHL Thank you for your question. SwaggerUI renders the schema models based on a predefined list of model types, and it is happenstance that "oneOf" is last to get parsed and rendered. There is no intentional ordering of "priorities" per se. So in this case, a schema model of a (default) "property" will get rendered first, followed by "allOf", then "oneOf".

     

  • HenrikHL's avatar
    HenrikHL
    Frequent Contributor

    It would be super nice if the SwaggerHub team (or anybody else) could answer if this is intended behavior or a bug...

  • Rache1's avatar
    Rache1
    SmartBear Alumni (Retired)

    Hi HenrikHL I have asked our team and will let you know as soon as I have an answer. Apologies and thank you for your patience. 

  • tlai's avatar
    tlai
    SmartBear Alumni (Retired)

    HenrikHL Thank you for your question. SwaggerUI renders the schema models based on a predefined list of model types, and it is happenstance that "oneOf" is last to get parsed and rendered. There is no intentional ordering of "priorities" per se. So in this case, a schema model of a (default) "property" will get rendered first, followed by "allOf", then "oneOf".