diff --git a/packages/react-openapi/src/OpenAPISchema.tsx b/packages/react-openapi/src/OpenAPISchema.tsx index 87f0ddb0b..6a9dfab7e 100644 --- a/packages/react-openapi/src/OpenAPISchema.tsx +++ b/packages/react-openapi/src/OpenAPISchema.tsx @@ -47,6 +47,9 @@ export function OpenAPISchemaProperty( ? null : getSchemaAlternatives(schema, new Set(circularRefs.keys())); + const shouldDisplayExample = (schema: OpenAPIV3.SchemaObject): boolean => { + return (typeof schema.example === 'string' || typeof schema.example === 'number' || typeof schema.example === 'boolean') + } return ( ) : null} + {shouldDisplayExample(schema) ? ( + Example: {JSON.stringify(schema.example)} + ) : null} } > diff --git a/packages/react-openapi/src/OpenAPISpec.tsx b/packages/react-openapi/src/OpenAPISpec.tsx index 7e2ab6afe..34bde07b6 100644 --- a/packages/react-openapi/src/OpenAPISpec.tsx +++ b/packages/react-openapi/src/OpenAPISpec.tsx @@ -48,6 +48,7 @@ export function OpenAPISpec(props: { rawData: any; context: OpenAPIClientContext // Description of the parameter is defined at the parameter level // we use display it if the schema doesn't override it description: parameter.description, + example: parameter.example, ...(noReference(parameter.schema) ?? {}), }, required: parameter.required, diff --git a/src/components/DocumentView/OpenAPI/style.css b/src/components/DocumentView/OpenAPI/style.css index 5f618fcea..00945d644 100644 --- a/src/components/DocumentView/OpenAPI/style.css +++ b/src/components/DocumentView/OpenAPI/style.css @@ -172,6 +172,10 @@ @apply prose-sm; } +.openapi-schema-example { + @apply prose-sm mt-2 text-dark/10 dark:text-light/10; +} + /** Authentication */ .openapi-securities {