Packages
arke_server
0.3.13
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.4.0-bulk.0
0.3.18
0.3.17
0.3.16
0.3.15
0.3.14
0.3.13
0.3.12
0.3.11
0.3.10
0.3.9
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.1.42
0.1.41
0.1.40
0.1.39
0.1.38
0.1.37
0.1.36
0.1.35
0.1.34
0.1.33
0.1.32
0.1.31
0.1.30
0.1.29
0.1.28
0.1.27
0.1.26
0.1.25
0.1.24
0.1.23
0.1.22
0.1.21
0.1.20
0.1.19
0.1.18
0.1.17
0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Arke server
Current section
Files
Jump to
Current section
Files
lib/openapi/schemas/example.ex
defmodule ArkeServer.Schemas do
alias OpenApiSpex.Schema
defmodule UnitStruct do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "Unit Struct",
description: "Struct of a unit",
type: :object,
properties: %{
label: %Schema{type: :string, example: "Test", description: "Label of the unit"},
parameters: %Schema{
type: :array,
description: "Parameters of the Unit",
items: [
oneOf: [
%OpenApiSpex.Reference{"$ref": "#/components/schemas/IntegerParameterUnit"},
%OpenApiSpex.Reference{"$ref": "#/components/schemas/StringParameterUnit"}
]
]
}
}
})
end
defmodule StringParameter do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "StringParameterUnit",
type: :object,
properties: %{
default: %Schema{
type: :string,
example: "Default value",
nullable: true,
description: "Default value of the parameter"
},
helper_text: %Schema{type: :string, nullable: true},
id: %Schema{
type: :string,
example: "first_name",
nullable: false,
description: "ID of the unit representing the parameter"
},
label: %Schema{
type: :string,
example: "I am a label",
nullable: false,
description: "Label of the unit"
},
max_length: %Schema{type: :integer, example: 100, description: "Max length of the string"},
min_length: %Schema{type: :integer, example: 3, description: "Min length of the string"},
type: %Schema{type: :string, example: "string", description: "Type of the parameter"}
}
})
end
defmodule IntegerParameter do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "IntegerParameterUnit",
type: :object,
properties: %{
default: %Schema{
type: :integer,
example: 7,
nullable: true,
description: "Default value of the parameter"
},
helper_text: %Schema{type: :string, nullable: true},
id: %Schema{
type: :string,
example: "age",
nullable: false,
description: "ID of the unit representing the parameter"
},
label: %Schema{
type: :string,
example: "I am a label",
nullable: false,
description: "Label of the unit"
},
max: %Schema{type: :integer, example: 100, description: "Max value"},
min: %Schema{type: :integer, example: 3, description: "Min value"},
type: %Schema{type: :string, example: "integer", description: "Type of the parameter"}
}
})
end
defmodule StringParameterUnit do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "String unit parameter",
description: "String unit parameter",
type: :object,
allOf: [
StringParameter,
%Schema{
type: :object,
properties: %{
value: %Schema{
example: "Test value",
type: :string
}
}
}
]
})
end
defmodule IntegerParameterUnit do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "Integer unit parameter",
description: "Integer unit parameter",
type: :object,
allOf: [
IntegerParameter,
%Schema{
type: :object,
properties: %{
value: %Schema{
example: 10,
type: :integer
}
}
}
]
})
end
defmodule UnitParameter do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "Parameter example",
description: "Some parameter for the Units",
type: :object,
properties: %{
parameter_1: %Schema{
type: :string,
example: "first_name",
nullable: true,
description: "One of the unit parameters"
},
parameter_2: %Schema{
type: :string,
example: "last_name",
nullable: false,
description: "Another unit parameter"
},
parameter_n: %Schema{
type: :string,
example: "[...]",
nullable: false,
description: "Another unit parameter"
}
}
})
end
defmodule CreateUnitExample do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "Create unit example",
description: "Create unit example",
type: :object,
allOf: [
UnitParameter
]
})
end
defmodule UnitExample do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "Unit example",
description: "Unit example",
type: :object,
allOf: [
%Schema{
type: :object,
properties: %{
arke_id: %Schema{
type: :string,
example: "id_arke_example",
description: "Arke ID"
},
id: %Schema{
type: :string,
example: "123e4567-e89b-12d3-a456-426614174000",
nullable: false,
description: "ID of the unit"
}
}
},
UnitParameter,
%Schema{
type: :object,
properties: %{
inserted_at: %Schema{
type: :string,
format: "date-time",
description: "When it has been created"
},
updated_at: %Schema{
type: :string,
format: "date-time",
description: "Last time it has been updated"
}
}
}
]
})
end
defmodule GroupExample do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "Group example",
description: "Group example",
type: :object,
properties: %{
arke_id: %Schema{
type: :string,
example: "id_group",
description: "Group ID"
},
arke_list: %Schema{
type: :array,
items: %{},
example: "[]",
description: "List of Arke linked to the group"
},
id: %Schema{
type: :string,
example: "group_1",
description: "UUID or value assigned during creation"
},
label: %Schema{
type: :string,
example: "I am the group label",
description: "Group label"
},
description: %Schema{
type: :string,
example:
"Consectetur aliquip sunt tempor incididunt Lorem sint ex mollit reprehenderit et anim",
nullable: false,
description: "Group Description"
},
inserted_at: %Schema{
type: :string,
format: "date-time",
description: "When it has been created"
},
updated_at: %Schema{
type: :string,
format: "date-time",
description: "Last time it has been updated"
}
}
})
end
defmodule UserExample do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "User example",
description: "User example",
type: :object,
properties: %{
address: %Schema{
type: :string,
nullable: true,
example: nil,
description: "Address"
},
first_name: %Schema{
type: :string,
example: "John",
nullable: true,
description: "First name of the user"
},
last_name: %Schema{
type: :string,
example: "Doe",
nullable: true,
description: "Last name of the user"
},
username: %Schema{
type: :string,
nullable: false,
example: "jdoe",
description: "Username of the user"
},
phone_number: %Schema{
type: :string,
example: "2124567890",
nullable: true,
description: "Phone Number"
},
type: %Schema{
type: :string,
example: "true",
nullable: false,
description: "Type of the user [customer, admin, super_admin]"
},
fiscal_code: %Schema{
type: :string,
example: nil,
nullable: true,
description: "Fiscal code"
}
}
})
end
defmodule UserParams do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "Signin Parameter",
description: "POST body for creating a user",
type: :object,
properties: %{
username: %Schema{
type: :string,
nullable: false,
description: "Username"
},
password: %Schema{
type: :string,
nullable: false,
description: "Password",
format: "password"
}
},
required: [:username, :password],
example: %{
"username" => "jdoe",
"password" => "jdoe_password"
}
})
end
end