Add property to every input schema #176
chriskolenko
started this conversation in
General
Replies: 1 comment
-
Hello, in this case I think the easiest would be to iterate OpenAPI spec value after it has been populated, and add needed shared parameters to all path items. Please check an example: https://github.com/swaggest/rest/blob/v0.2.59/_examples/advanced/router.go#L183-L196 for p, pi := range r.Spec.Paths.MapOfPathItemValues {
pi.Parameters = append(pi.Parameters, openapi3.ParameterOrRef{
Parameter: (&openapi3.Parameter{
In: openapi3.ParameterInHeader,
Name: "X-Umbrella-Header",
Schema: &openapi3.SchemaOrRef{
Schema: (&openapi3.Schema{}).WithType(openapi3.SchemaTypeString),
},
}).WithDescription("This request header is supported in all operations."),
})
r.Spec.Paths.MapOfPathItemValues[p] = pi
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to add a Header to every model. Is there a nice way to doing so?
For example
X-Organisation-Id
I'll then use a middleware to handle this header value.
Beta Was this translation helpful? Give feedback.
All reactions