Skip to content

Commit

Permalink
[RTC-218/219] Fix OpenApi bugs (fishjam-dev#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
LVala authored Apr 17, 2023
1 parent 3aa3c4e commit 6f020be
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 13 deletions.
3 changes: 2 additions & 1 deletion lib/jellyfish_web/api_spec/component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ defmodule JellyfishWeb.ApiSpec.Component do
properties: %{
id: %Schema{type: :string, description: "Assigned component id", example: "component-1"},
type: Type
}
},
required: [:id, :type]
})
end
3 changes: 2 additions & 1 deletion lib/jellyfish_web/api_spec/error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defmodule JellyfishWeb.ApiSpec.Error do
description: "Error details",
example: "Token has expired"
}
}
},
required: [:errors]
})
end
6 changes: 3 additions & 3 deletions lib/jellyfish_web/api_spec/peer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ defmodule JellyfishWeb.ApiSpec.Peer do
properties: %{
id: %Schema{type: :string, description: "Assigned peer id", example: "peer-1"},
type: Type,
status: Status,
token: Token
}
status: Status
},
required: [:id, :type, :status]
})
end
7 changes: 6 additions & 1 deletion lib/jellyfish_web/api_spec/responses.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[
{PeerDetailsResponse, "Response containing peer details", JellyfishWeb.ApiSpec.Peer},
{PeerDetailsResponse, "Response containing peer details and their token",
%OpenApiSpex.Schema{
type: :object,
properties: %{peer: JellyfishWeb.ApiSpec.Peer, token: JellyfishWeb.ApiSpec.Peer.Token},
required: [:peer, :token]
}},
{RoomDetailsResponse, "Response containing room details", JellyfishWeb.ApiSpec.Room},
{ComponentDetailsResponse, "Response containing component details",
JellyfishWeb.ApiSpec.Component},
Expand Down
3 changes: 2 additions & 1 deletion lib/jellyfish_web/api_spec/room.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ defmodule JellyfishWeb.ApiSpec.Room do
type: :array,
items: Peer
}
}
},
required: [:id, :config, :components, :peers]
})
end
2 changes: 1 addition & 1 deletion lib/jellyfish_web/controllers/peer_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule JellyfishWeb.PeerController do
description: "Room ID",
type: :string
],
peer_id: [
id: [
in: :path,
description: "Peer id",
type: :string
Expand Down
30 changes: 25 additions & 5 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ components:
type: string
type:
$ref: '#/components/schemas/ComponentType'
required:
- id
- type
title: Component
type: object
x-struct: Elixir.JellyfishWeb.ApiSpec.Component
Expand Down Expand Up @@ -50,6 +53,8 @@ components:
description: Error details
example: Token has expired
type: string
required:
- errors
title: Error
type: object
x-struct: Elixir.JellyfishWeb.ApiSpec.Error
Expand All @@ -62,18 +67,28 @@ components:
type: string
status:
$ref: '#/components/schemas/PeerStatus'
token:
$ref: '#/components/schemas/AuthToken'
type:
$ref: '#/components/schemas/PeerType'
required:
- id
- type
- status
title: Peer
type: object
x-struct: Elixir.JellyfishWeb.ApiSpec.Peer
PeerDetailsResponse:
description: Response containing peer details
description: Response containing peer details and their token
properties:
data:
$ref: '#/components/schemas/Peer'
properties:
peer:
$ref: '#/components/schemas/Peer'
token:
$ref: '#/components/schemas/AuthToken'
required:
- peer
- token
type: object
required:
- data
title: PeerDetailsResponse
Expand Down Expand Up @@ -111,6 +126,11 @@ components:
items:
$ref: '#/components/schemas/Peer'
type: array
required:
- id
- config
- components
- peers
title: Room
type: object
x-struct: Elixir.JellyfishWeb.ApiSpec.Room
Expand Down Expand Up @@ -430,7 +450,7 @@ paths:
type: string
- description: Peer id
in: path
name: peer_id
name: id
required: true
schema:
type: string
Expand Down

0 comments on commit 6f020be

Please sign in to comment.