I'm adding swagger spec extensions for the first t...
# http4k
d
I'm adding swagger spec extensions for the first time, and struggling with how to encapsulate the extension data within each route specification. Using this yaml swagger snippet as an example:
Copy code
paths:
  /api/foo:
    x-data_classification: PUBLIC
    get:
      summary: Does the foo
      x-incident_priority: P3
  /api/bar:
    x-data_classification: INTERNAL
    get:
      summary: Does the bar
      x-incident_priority: P1
It looks like the
OpenApiExtension
interface gives access to the top-level node for me to insert the extension metadata, but this appears like I'd need to manage the route information in two places. What seems like a more natural place to add the metadata is in the route definition. Is this feasible (e.g. in
RouteMeta
as a Map), or am I missing some other better way to add the extension information? i.e. Where's a good place to code information like
x-data-classification
(at the path/ level) and
x-incident-priority
(at the path/method level)?
d
The current extension mechanism is a bit of a blunt instrument tbh. Is it actually legal in the openapi spec to add metadata where you want to add it?
d
yeah if i'm reading this right: https://swagger.io/docs/specification/openapi-extensions/
info
section
paths
section, individual paths and operations
• operation parameters
responses
tags
• security schemes