Replies: 1 comment 4 replies
-
Hi @bangalcat, thanks for the suggestion. I'm considering a few options for this. Using the examples from https://swagger.io/docs/specification/describing-parameters/#default 1) Forward all additional opts from Parameter to Schema operation :search,
summary: "Search for items",
parameters: [
offset: [
in: :query,
type: :integer,
minimum: 0,
default: 0,
required: false,
description: "The number of items to skip before starting to collect the result set."
],
limit: [
in: :query,
type: :integer,
minimum: 1,
maximum: 100,
default: 20,
required: false,
description: "The number of items to return."
]
], This intentionally blurs the line between 2) Keyword schema operation :search,
summary: "Search for items",
parameters: [
offset: [
in: :query,
required: false,
description: "The number of items to skip before starting to collect the result set.",
schema: [
type: :integer,
minimum: 0,
default: 0
]
],
limit: [
in: :query,
required: false,
description: "The number of items to return.",
schema: [
type: :integer,
minimum: 1,
maximum: 100,
default: 20
]
]
] This reduces some noise when describing the schema, although it introduces inconsistency with how schemas are usually declared and doesn't help to reduce nesting. 3) Struct schema operation :search,
summary: "Search for items",
parameters: [
offset: [
in: :query,
required: false,
description: "The number of items to skip before starting to collect the result set.",
schema: %Schema{
type: :integer,
minimum: 0,
default: 0
}
],
limit: [
in: :query,
required: false,
description: "The number of items to return.",
schema: %Schema{
type: :integer,
minimum: 1,
maximum: 100,
default: 20
}
]
], For comparison, explicit struct schemas. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I've recently used this library and it's awesome! Really appreciate for you.
I have a tiny proposal. I've realized that you provide some convenience for defining operations, like in
parameters
, I can usetype: :integer
instead of%Schema{}
. It is really useful! But I often need adefault
value for that parameter. So I think it would be great if there is another convenient optiondefault
inparameters
.Though I cannot totally sure about that, want to know your opinions. Thanks again!
Beta Was this translation helpful? Give feedback.
All reactions