MCPcopy Create free account
hub / github.com/a-h/rest / getModelName

Method getModelName

schema.go:171–185  ·  view source on GitHub ↗
(t reflect.Type)

Source from the content-addressed store, hash-verified

169}
170
171func (api *API) getModelName(t reflect.Type) string {
172 pkgPath, typeName := t.PkgPath(), t.Name()
173 if t.Kind() == reflect.Pointer {
174 pkgPath = t.Elem().PkgPath()
175 typeName = t.Elem().Name() + "Ptr"
176 }
177 if t.Kind() == reflect.Map {
178 typeName = fmt.Sprintf("map[%s]%s", t.Key().Name(), t.Elem().Name())
179 }
180 schemaName := api.normalizeTypeName(pkgPath, typeName)
181 if typeName == "" {
182 schemaName = fmt.Sprintf("AnonymousType%d", len(api.models))
183 }
184 return schemaName
185}
186
187func getSchemaReferenceOrValue(name string, schema *openapi3.Schema) *openapi3.SchemaRef {
188 if shouldBeReferenced(schema) {

Callers 5

RegisterModelMethod · 0.95
renderMethod · 0.80
renderMethod · 0.80
renderMethod · 0.80
renderMethod · 0.80

Calls 1

normalizeTypeNameMethod · 0.95

Tested by

no test coverage detected