profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/mbuhot/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Mike Buhot mbuhot Brisbane, Australia https://www.linkedin.com/in/michael-buhot Functional Programming enthusiast from Brisbane, Australia

mbuhot/ecto_job 251

Transactional job queue with Ecto, PostgreSQL and GenStage

mbuhot/eskotlin 118

Elasticsearch Query DSL for Kotlin

mbuhot/ex_module_params 34

Parameterized Modules for Elixir

mbuhot/chinook 15

Explore the Chinook Database

mbuhot/ecto_row_level_security 12

Demonstration of postgres row level security policies using Elixir/Ecto

mbuhot/awesome-elixir 1

A curated list of amazingly awesome Elixir and Erlang libraries, resources and shiny things. Updates:

mbuhot/BoringWebApp 1

An F# web app that attempts to be familiar to ASP.NET core users

mbuhot/absinthe 0

The GraphQL toolkit for Elixir

mbuhot/advent2020 0

Advent of Code 2020 solutions

mbuhot/analytics-elixir 0

Segment.com library for Elixir

startedQqwy/elixir-type_check

started time in a day

issue commentopen-api-spex/open_api_spex

Move schema definition to inside functions

Sounds good to me @josevalim 👍

josevalim

comment created time in 5 days

issue commentopen-api-spex/open_api_spex

Move schema definition to inside functions

Thanks @JesseHerrick 👍

I think we can adopt @josevalim's suggestion to expand aliases appearing in the schema. The examples are a bit problematic, since the call to Schema.example(Generic.Slug) will be evaluated at compile time.

We could:

  1. Provide an optimisation where we detect that a map literal is given to OpenApiSpex.schema containing an example key, remove the example from the map and evaluate it at runtime inside the generated schema/0 function.

  2. Provide a syntax for generating examples from schemas during schema resolution, eg:

      example: %{
        slug: {:example_of, Generic.Slug},
        currency: {:example_of, Currency},
        property: {:example_of, PropertyContext.Property},
        endpoint_example: {:example_of, EndpointExample},
        datetime: nil,
        message: nil
      }

There are some edge cases where compile-time dependencies are necessary. One case is when an object type schema uses allOf, eg:

defmodule Cat do
  OpenApiSpex.schema(%{
    title: "Cat",
    allOf: [Animal, Meow]
  })
end

To define the %Cat{} struct for that schema, the properties of Animal and Meow will need to be resolved at compile-time.

josevalim

comment created time in 5 days

issue commentopen-api-spex/open_api_spex

Move schema definition to inside functions

Hi @josevalim thanks for opening the discussion 👋

I would like to start a discussion about moving the schema definitions inside a schema function.

The good news is that it already works this way fundamentally: https://github.com/open-api-spex/open_api_spex/blob/master/lib/open_api_spex/schema.ex#L143-L147

Any module that exposes a schema/0 function returning a %Schema{} struct can be used. Any additional functionality added by the schema/1 macro should be considered a convenience.

Another place where you may need to keep the compile-time behaviour is in the operation macro in controllers

Similarly to the schemas, the operation macros shouldn't be doing too much compile time work other than de-sugaring the DSL to a function definition, which shouldn't have compile time dependencies on the schemas, it should only be using their module names.

In general when an Operation or Schema needs to reference another schema, it can be done using the name of the module containing the schema, and resolved to a %Schema{} struct at runtime using OpenApiSpex.resolve_schema_modules/1 (https://github.com/open-api-spex/open_api_spex/blob/master/lib/open_api_spex.ex#L20-L37)

Are you able to share an example that demonstrates the problem with compilation times?

josevalim

comment created time in 6 days

push eventopen-api-spex/open_api_spex

Joel C

commit sha 1a36e44360ceb554ba56e3b9abc95f520cd5ad44

Fix JsonErrorResponse schema definition (#383) * Fix JsonErrorResponse schema definition The `OpenApiSpex.JsonErrorResponse` schema did not contain a type for its error items, this caused generated responses from `OpenApiSpex.Plug.CastAndValidate` to not match with errors like: ``` Value does not conform to schema JsonErrorResponse: Invalid schema.type. Got: nil at /errors/0 %{"errors" => [%{"detail" => "Invalid value for enum", "source" => %{"pointer" => "/type"}, "title" => "Invalid value"}]} ```

view details

push time in 6 days

PR merged open-api-spex/open_api_spex

Fix JsonErrorResponse schema definition

Fixes: #384

The OpenApiSpex.JsonErrorResponse schema did not contain a type for its error items, this caused generated responses from OpenApiSpex.Plug.CastAndValidate to not match JsonErrorResponse with errors like:

Value does not conform to schema JsonErrorResponse: Invalid schema.type. Got: nil at /errors/0
     %{"errors" => [%{"detail" => "Invalid value for enum", "source" => %{"pointer" => "/type"}, "title" => "Invalid value"}]}

+20 -2

0 comment

3 changed files

vorce

pr closed time in 6 days

issue closedopen-api-spex/open_api_spex

Default error responses from the CastAndValidate plug doesn't match JsonErrorResponse

Default error responses from the CastAndValidate plug doesn't match JsonErrorResponse.

This is the error when using assert_schema:

Value does not conform to schema JsonErrorResponse: Invalid schema.type. Got: nil at /errors/0
     %{"errors" => [%{"detail" => "Invalid value for enum", "source" => %{"pointer" => "/type"}, "title" => "Invalid value"}]}

Cause:

There seems to be a missing type for the JsonErrorResponse schema in its errors items.

closed time in 6 days

vorce
PullRequestReviewEvent

PR closed mbuhot/chinook

Bump path-parse from 1.0.6 to 1.0.7 in /assets dependencies

Bumps path-parse from 1.0.6 to 1.0.7. <details> <summary>Commits</summary> <ul> <li>See full diff in <a href="https://github.com/jbgutierrez/path-parse/commits/v1.0.7">compare view</a></li> </ul> </details> <br />

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


<details> <summary>Dependabot commands and options</summary> <br />

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the Security Alerts page.

</details>

+3 -3

0 comment

1 changed file

dependabot[bot]

pr closed time in 22 days

PR opened pow-auth/assent

Propagate existing RequestError in fetch_openid_configuration

Assent.Strategy.request can return RequestError{error: :unreachable} in OIDC.fetch_openid_configuration/1.

Passing an existing %RequestError{} struct into RequestError.invalid/1 causes a KeyError accessing the :status field.

The changes in this PR pattern match to handle %RequestError{} and return it.

+3 -0

0 comment

1 changed file

pr created time in 22 days

create barnchteam-alembic/assent

branch : fix-oidc-unreachable-request-error

created branch time in 22 days

fork mbuhot/assent

Multi-provider framework in Elixir

https://powauth.com

fork in 22 days

Pull request review commentopen-api-spex/open_api_spex

fix: cast discriminator when value has atom keys

 defmodule OpenApiSpex.Cast.Discriminator do   defp cast_discriminator(%_{value: value, schema: schema} = ctx) do     {discriminator_property, mappings} = discriminator_details(schema) -    case Map.pop(value, "#{discriminator_property}") do-      {"", _} ->+    case value["#{discriminator_property}"] || value[:"#{discriminator_property}"] do

discriminator_property is an atom here. No need to wrap it in :"#{...}" right?

    case value["#{discriminator_property}"] || value[discriminator_property] do
igormq

comment created time in a month

PullRequestReviewEvent

Pull request review commentopen-api-spex/open_api_spex

fix: cast discriminator when value has atom keys

 defmodule OpenApiSpex.CastDiscriminatorTest do       assert expected == cast_cast(value: input_value, schema: discriminator_schema)     end +    test "nested, atom map success", %{schemas: %{dog: dog, cat: cat}} do+      # "animal_type" is the discriminator and the keys need to be strings.

Does this comment still apply? Looks like the keys are atoms in input_value

igormq

comment created time in a month

PullRequestReviewEvent

PR closed mbuhot/chinook

Bump postcss from 7.0.32 to 7.0.36 in /assets dependencies

Bumps postcss from 7.0.32 to 7.0.36. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/postcss/postcss/releases">postcss's releases</a>.</em></p> <blockquote> <h2>7.0.36</h2> <ul> <li>Backport ReDoS vulnerabilities from PostCSS 8.</li> </ul> <h2>7.0.35</h2> <ul> <li>Add <a href="https://github.com/postcss/postcss/wiki/PostCSS-8-for-end-users">migration guide link</a> to PostCSS 8 error text.</li> </ul> <h2>7.0.34</h2> <ul> <li>Fix compatibility with <code>postcss-scss</code> 2.</li> </ul> <h2>7.0.33</h2> <ul> <li>Add error message for PostCSS 8 plugins.</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/postcss/postcss/blob/main/CHANGELOG.md">postcss's changelog</a>.</em></p> <blockquote> <h2>7.0.36</h2> <ul> <li>Backport ReDoS vulnerabilities from PostCSS 8.</li> </ul> <h2>7.0.35</h2> <ul> <li>Add migration guide link to PostCSS 8 error text.</li> </ul> <h2>7.0.34</h2> <ul> <li>Fix compatibility with <code>postcss-scss</code> 2.</li> </ul> <h2>7.0.33</h2> <ul> <li>Add error message for PostCSS 8 plugins.</li> </ul> <h2>7.0.36</h2> <ul> <li>Backport ReDoS vulnerabilities from PostCSS 8.</li> </ul> <h2>7.0.35</h2> <ul> <li>Add migration guide link to PostCSS 8 error text.</li> </ul> <h2>7.0.34</h2> <ul> <li>Fix compatibility with <code>postcss-scss</code> 2.</li> </ul> <h2>7.0.33</h2> <ul> <li>Add error message for PostCSS 8 plugins.</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/postcss/postcss/commit/67e3d7b3402c5d3d036ab7c1e781f86910d6ca72"><code>67e3d7b</code></a> Release 7.0.36 version</li> <li><a href="https://github.com/postcss/postcss/commit/54cbf3c4847eb0fb1501b9d2337465439e849734"><code>54cbf3c</code></a> Backport ReDoS vulnerabilities from PostCSS 8</li> <li><a href="https://github.com/postcss/postcss/commit/12832f3d203474bd273bd06bd3b2407567bfe09e"><code>12832f3</code></a> Release 7.0.35 version</li> <li><a href="https://github.com/postcss/postcss/commit/4455ef6baf84ceea87cb662131f95d798063896c"><code>4455ef6</code></a> Use OpenCollective in funding</li> <li><a href="https://github.com/postcss/postcss/commit/e867c794b5d646839350dd4b76f3cc81423413e6"><code>e867c79</code></a> Add migration guide to PostCSS 8 error</li> <li><a href="https://github.com/postcss/postcss/commit/32a22a98bc4de9c7a2489041ceae24eedc62144f"><code>32a22a9</code></a> Release 7.0.34 version</li> <li><a href="https://github.com/postcss/postcss/commit/22939829688574b9acdbd29106ca2ec9470b2b17"><code>2293982</code></a> Lock build targets</li> <li><a href="https://github.com/postcss/postcss/commit/2c3a111a940b373a60fae196e63931b3b6e9d8ca"><code>2c3a111</code></a> Release 7.0.33 version</li> <li><a href="https://github.com/postcss/postcss/commit/4105f21b48d75847e822e89746633792c478922b"><code>4105f21</code></a> Use yaspeller instead of yaspeller-ci</li> <li><a href="https://github.com/postcss/postcss/commit/c8d02a0da503f9fa5d96a854a2c9244710c18c72"><code>c8d02a0</code></a> Revert yaspeller-ci removal</li> <li>Additional commits viewable in <a href="https://github.com/postcss/postcss/compare/7.0.32...7.0.36">compare view</a></li> </ul> </details> <br />

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


<details> <summary>Dependabot commands and options</summary> <br />

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the Security Alerts page.

</details>

+3 -3

0 comment

1 changed file

dependabot[bot]

pr closed time in 2 months

PR opened schrockwell/bodyguard

Fix docs for Bodyguard.scope

Noticed what looks like a copy & paste error while reading the docs. I think Bodyguard.Policy.authorize should be Bodyguard.Schema.scope in docs for Bodyguard.scope.

+1 -1

0 comment

1 changed file

pr created time in 2 months

push eventmbuhot/bodyguard

Mike Buhot

commit sha 6f2c48deae6115c1a10f3bbcc518b78fd5b5fe69

Fix docs for Bodyguard.scope Docs incorrectly said that `Bodyguard.scope/4` would call a `Bodyguard.Policy.authorize/3` callback.

view details

push time in 2 months

fork mbuhot/bodyguard

Simple authorization conventions for Phoenix apps

https://hexdocs.pm/bodyguard/

fork in 2 months

issue commentopen-api-spex/open_api_spex

cast_and_validate purges file upload struct from controller parameters

Looks like when we CastAndValidate a schema with type: :string, format: :binary it should allow a %Plug.Upload{} struct to be passed through.

https://swagger.io/docs/specification/describing-request-body/file-upload/

superruzafa

comment created time in 2 months

Pull request review commentopen-api-spex/open_api_spex

Improve CI pipeline

 defmodule OpenApiSpexTest.ApiSpec do+  @moduledoc false

Why add this attribute to a test support file? If this is from a credo check then I suggest we disable it.

lucacorti

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentopen-api-spex/open_api_spex

Improve CI pipeline

 defmodule OpenApiSpex.Schema do   """   defdelegate cast(schema, value, schemas), to: DeprecatedCast -  @doc ~S"""

why?

lucacorti

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentopen-api-spex/open_api_spex

Improve CI pipeline

 defmodule OpenApiSpex.Plug.AppEnvCache do+  @moduledoc false

Not sure we should hide this module from the docs. Users on older OTP versions will need to configure their cache to use it.

lucacorti

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentopen-api-spex/open_api_spex

Improve CI pipeline

 defmodule OpenApiSpex.Cast.Number do     end   end -  # TODO We need a way to distinguish numbers in (JSON) body vs in request parameters

Is this TODO no longer relevant?

lucacorti

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentopen-api-spex/open_api_spex

Improve CI pipeline

 defmodule OpenApiSpex.Cast do+  @moduledoc false

Why? There's documented functions in this module.

lucacorti

comment created time in 2 months