OpenAPI-Specification icon indicating copy to clipboard operation
OpenAPI-Specification copied to clipboard

Proposal - extract Swagger Examples into separate files of mappings.

Open ptoora opened this issue 6 years ago • 3 comments

Examples (plus swagger) can be used as the basis for stubs/mocks. If we can separate these out from the Swagger files, ideally in a Wiremock Mapping style, then the combination of the Swagger plus the Mappings will mean that, with existing open source offerings (eg. https://github.com/telegraph/swagger-stub), we can stand-up a stub/mock very quickly. This will also neatly draw design and implementation closer.

ptoora avatar Apr 09 '18 15:04 ptoora

Examples can be separated out into a different file using the externalValue property of the example object. Is this sufficient for your needs?

darrelmiller avatar Apr 09 '18 17:04 darrelmiller

Ping @ptoora

MikeRalphson avatar Jul 25 '19 17:07 MikeRalphson

I am evaluating this as a possible use case for overlays, https://github.com/OAI/Overlay-Specification/discussions/9.

Possibly overlays could help here, examples could be defined in overlay file, that would technically meet the requirement of having examples in a separate file. Not sure that is any better than using externalValue mentioned previously though.

Tooling could also be used (for ex jq) to parse a contract quickly and extract/transform the examples, to a separate file if need be. This makes overlay the wrong way to handle this use case.

kscheirer avatar Aug 25 '22 01:08 kscheirer

It sounds like externalValue was the main answer, and further work is taking place in Overlays. I'm going to close this as answered / part of another project.

handrews avatar Jan 27 '24 02:01 handrews