I have API yaml specification that defines what should be the response from each endpoint, e.g. I want that /version
returns version1.0
as defined:
openapi: "3.0.3"
info:
title: "TITLE"
description: "DESCRIPTION"
version: "1.0.0"
paths:
/version:
get:
description: "description"
responses:
"200":
description: "description"
content:
application/json:
schema:
$ref: '#/components/schemas/version'
components:
schemas:
version:
type: object
properties:
version:
type: string
example:
"version": "version1.0"
API server that runs on Swaggerhub works like expected, but e.g. python-flask server stub generated by Swaggerhub and run locally on my machine returns do some magic!
for every endpoint and not the example
provided in yaml. The same with server stubs generated using swagger-codegen and openapi-generator.
I am mainly interested in making it work for openapi-generator generated server stub.
This is working as expected.
The example
tag is an OpenAPI tag to provide an example object or schema to your users to demonstrate the use of your APIs. The virtual service provided by SwaggerHub (virtserver
) is able to interpret example
value and return these values when you make API calls to virtualized service provided by SwaggerHub.
On the other hand, codegen may or may not handle example
tags in the same way (it depends on the codegen template). I have two recommendations about how to go about resolving this: