From 364ba58801aa0c9b3f4270cf573786e7f66bb5f6 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 19 May 2021 16:37:51 +0900 Subject: [PATCH] Expose openapi3.Schema in the Schema object --- pkg/codegen/schema.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/codegen/schema.go b/pkg/codegen/schema.go index a476a9f96b..380ce65dae 100644 --- a/pkg/codegen/schema.go +++ b/pkg/codegen/schema.go @@ -25,6 +25,9 @@ type Schema struct { SkipOptionalPointer bool // Some types don't need a * in front when they're optional Description string // The description of the element + + // The original OpenAPIv3 Schema. + OAPISchema *openapi3.Schema } func (s Schema) IsRef() bool { @@ -162,6 +165,7 @@ func GenerateGoSchema(sref *openapi3.SchemaRef, path []string) (Schema, error) { outSchema := Schema{ Description: StringToGoComment(schema.Description), + OAPISchema: schema, } // We can't support this in any meaningful way @@ -184,6 +188,7 @@ func GenerateGoSchema(sref *openapi3.SchemaRef, path []string) (Schema, error) { if err != nil { return Schema{}, errors.Wrap(err, "error merging schemas") } + mergedSchema.OAPISchema = schema return mergedSchema, nil }