Git Product home page Git Product logo

Comments (4)

mbuhot avatar mbuhot commented on August 17, 2024

Hi @Lazarus404, with the current version of open_api_spex, you get the path/query params merged into the requestBody struct if the schema allows additionalProperties.

It feels like a hack, so I wonder if there is a better way?

Some ideas that come to mind:

  1. Store the result of casting the request body in conn.body_params?
    This would require matching on body_params separately to the query/path params in controllers:
def create(conn = %{body_params: body = %UserRequest{}}, params = %{id: id}) do
... use id and body 
  1. Store the cast body in a reserved key like :"$body" in the combined params map?
def create(conn, params = %{id: id,  "$body": body = %UserRequest{}}) do
... use id and body 

What do you think?

from open_api_spex.

Lazarus404 avatar Lazarus404 commented on August 17, 2024

I think option 1 would be more correct. This way, no toes are ever stood on. It has my vote.

from open_api_spex.

mbuhot avatar mbuhot commented on August 17, 2024

@Lazarus404 I've put together a change in #39

from open_api_spex.

mbuhot avatar mbuhot commented on August 17, 2024

Resolved in #39, thanks for reporting this @Lazarus404 👍

from open_api_spex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.