Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing object properties when using allOf on nested structures (one allOf object inside other) #565

Open
jkmrto opened this issue Sep 18, 2023 · 0 comments

Comments

@jkmrto
Copy link

jkmrto commented Sep 18, 2023

It looks like when using nested structure with allOf the properties of the inner object are not rendered properly by Swagger UI. Eg: render one object that is defined with allOf inside other object that is also using allOf.

For example, with this schema structure:

{
   container: {
          other_field: {}
          inner: {
                other_inner_field
                FieldA
                FieldB
           }
      }
}

Defining Container and Inner as:

defmodule Container do
    def schema do
      %Schema{
        type: :object,
        allOf: [
          ContainerTemplate,
          %Schema{
            type: :object,
            properties: %{
              links: %Schema{
                type: :object,
                properties: %{
                   inner: Inner
                },
              }
            }
          }
        ]
      }
    end
end

defmodule Inner do
    def schema do
      %Schema{
        type: :object,
        allOf: [
          InnerTemplate,
          %Schema{
            type: :object,
            properties: %{
              links: %Schema{
                type: :object,
                properties: %{
                   FieldA: %Schema{type: :string},
                   FieldB: %Schema{type: :string}
                },
              }
            }
          }
        ]
      }
    end
end

Since both Container and Inner objects makes use of allOf, the properties FieldA and FieldB wont be rendered in the Swagger UI.

However, the properties are present on the Schemas generated by open-api-spex, so it doesn't look like an issue on the library, it looks more like an issue in the renderer.

On the other hand, this is a known issue on the Swagger renderer swagger-api/swagger-editor#2765 (comment), and one possible workaround to it is moving the paths field above the components on the JSON generated.

So, if the path field were in the top on the generated JSON specs, the properties of Inner would be rendered properly:

Captura de pantalla 2023-09-18 a las 11 26 55

It is possible to control de order of the fields in the JSON specs generated? Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant