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

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

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
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
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
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
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
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130579 1222
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40082 209
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement