<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="252102" data-post-id="252102">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jgallinari" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jgallinari/120/26709_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jgallinari
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hello,</p>
<p>I’ve got a question regarding the use of <code>:minimum</code>.</p>
<p>I’m using</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">   plug OpenApiSpex.Plug.CastAndValidate, json_render_error_v2: true
</code></pre>
<p>for implicit validation on my Phoenix requests.</p>
<p>If you happen to define a schema like in:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyAppWeb.ApiSpec.Quantity do
  alias OpenApiSpex.Schema
  require OpenApiSpex

  OpenApiSpex.schema(%{
    type: :object,
    properties: %{
      quantity: %Schema{type: :integer, minimum: 1, description: "Quantity requested"}
    }
  })
end
</code></pre>
<p>you may get different types of error for say a request body containing <code>%{quantity: 0}</code> depending on how you use this schema.</p>
<p>E.g. While using :oneOf like in:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyAppWeb.ApiSpec.Items do
  alias OpenApiSpex.Schema
  require OpenApiSpex

  OpenApiSpex.schema(%{
    type: :object,
    properties: %{
        items: %Schema{oneOf: [MyAppWeb.ApiSpec.Quantity, ...]}
    }
  })
end
</code></pre>
<p>you will get:</p>
<p>[%{“detail” =&gt; “Failed to cast value to one of: no schemas validate”, “source” =&gt; %{“pointer” =&gt; “/items”}, “title” =&gt; “Invalid value”}]</p>
<p>But if you try to use it directly, like in:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyAppWeb.ApiSpec.Items do
  alias OpenApiSpex.Schema
  require OpenApiSpex

  OpenApiSpex.schema(%{
    type: :object,
    properties: %{
        items: MyAppWeb.ApiSpec.Quantity
    }
  })
end
</code></pre>
<p>then you will get a nicer message:</p>
<p>[%{“detail” =&gt; “0 is smaller than inclusive minimum 1”, “source” =&gt; %{“pointer” =&gt; “/items/quantity”}, “title” =&gt; “Invalid value”}]</p>
<p>So, if you have multiple schemas to check in your :oneOf, your request will basically fail because it won’t match, but you won’t know why.<br>
Can this be avoided?</p>
<p>Thanks</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="252102" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/openapispex-openapi-swagger-3-0-for-plug-apis/15614/52">Post #51</a>
	                </div>
	            </div>
              <div id="likers-container-252102" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="252102"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #51"></div>
  </section>
</div>
    <div class="postbit" id="252384" data-post-id="252384">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="moxley" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/moxley/120/37673_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  moxley
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/jgallinari" rel="nofollow">@jgallinari</a>, this is a limitation of the way errors are calculated and represented for polymorphic types such as <code>oneOf</code>. OpenApiSpex will need to be enhanced to carry forward errors from the child type up through the parent type. Feel free to submit a feature request on the Github page: <a href="https://github.com/open-api-spex/open_api_spex" class="inline-onebox" rel="noopener nofollow ugc">GitHub - open-api-spex/open_api_spex: Open API Specifications for Elixir Plug applications · GitHub</a>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="252384" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/openapispex-openapi-swagger-3-0-for-plug-apis/15614/53">Post #52</a>
	                </div>
	            </div>
              <div id="likers-container-252384" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="252384"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #52"></div>
  </section>
</div>
    <div class="postbit" id="326121" data-post-id="326121">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="aloukissas" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/aloukissas/120/21787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  aloukissas
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Is it possible to use this with Phoenix Channels to define the request and response types?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="326121" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/openapispex-openapi-swagger-3-0-for-plug-apis/15614/54">Post #53</a>
	                </div>
	            </div>
              <div id="likers-container-326121" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="326121"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #53"></div>
  </section>
</div>
    <div class="postbit" id="326503" data-post-id="326503">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mbuhot" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mbuhot/120/33444_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mbuhot
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You could define the schemas for those messages, but there isn’t any support for <code>CastAndValidate</code> on Channels.</p>
<p>Maybe the library could be extended to output an <a href="https://www.asyncapi.com/en" rel="noopener nofollow ugc">AsyncAPI</a> spec for the channels along with an OpenAPI spec for the HTTP endpoints.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="326503" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/openapispex-openapi-swagger-3-0-for-plug-apis/15614/55">Post #54</a>
	                </div>
	            </div>
              <div id="likers-container-326503" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="326503"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>