Configure metadata for Go models
mainMetadata can be provided to the generator via several layers:
- Field Tags: Use
openapi:"..."tags on Go struct fields (e.g.,openapi:"format=uuid;readOnly;minLength=3"). - External Registry Overrides: Use
WithTypeSchema,WithFieldSchema, orWithFieldSchemaByJSONNameduring generator initialization. - Type-level Providers: Implement
OpenAPISchema() *base.SchemaProxyon your types.
Key Configuration Options:
WithOpenAPITags(true): Includes compactopenapitags in generated Go models for metadata that reflection cannot infer (e.g.,format,title,description,enum,const).WithSchemaMetadataSidecar(true): Generates aschema_metadata.gofile containing typed Go data viaOpenAPISchemaMetadata() any. This allows high-fidelity reflection without requiring the model package to importlibopenapior carry escaped YAML strings.
gen := golang.NewGenerator(
golang.WithFieldSchema(reflect.TypeOf(BookingPayment{}), "Source", sourceSchema),
golang.WithFieldSchemaByJSONName(reflect.TypeOf(BookingPayment{}), "status", statusSchema),
)