nikolis

nikolis

Open Api Specs problem

Hello Fellas,

I am trying to use Open API Spex but as off this point with not much success.

I have been trying to define my schemass like following:

defmodule UserInstrument do
        
    OpenApiSpex.schema(%{
      title: "UserProfile",
      description: "Just a user profile",
      type: :object,
      properties: %{
        level: %Schema{type: :string, description: "The level of the user for the particular instrument"},
        instrument: %Schema{type: :string, description: "The musical instrument name also unique idendifier for the instrument"}
      },    
      required: [:level, :instrument],
      example: %{
        "level" => "V0",
        "instrument" => "piano"
      }
    })      
  end       
            
  defmodule UserProfile do
        
    OpenApiSpex.schema(%{
      title: "UserProfile",
      description: "Just a user profile",
      type: :object,           
      properties: %{
        email: %Schema{type: :string, description: "The user email"},
        id: %Schema{type: :integer, description: "unique identifier"},
        instruments: %Schema{type: :array, items: UserInstrument}

      },
      required: [:email, :id, :instruments],
      example: %{
        "id" => 12,
        "email" => "someemail@server.com"
      }
    })
  end

end

But somehow when I generate the schemas swagger fails to pick up the relationship between user profile and the instrument. This is also a problem when I am trying to do schema testing in my rest responses.

Am I missing something here ?
Or is this a bug of the implmentation library ?

Most Liked Responses

mbuhot

mbuhot

Looks like those schemas have the same title. Try changing one and see if that fixes your issue.

Where Next?

Popular in Questions Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement