add ks-iam and ks-apigateway

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2019-03-08 11:09:05 +08:00
parent f579e97f6b
commit b59c244ca2
715 changed files with 108638 additions and 23446 deletions

24
vendor/github.com/emicklei/go-restful-openapi/definition_builder.go generated vendored Normal file → Executable file
View File

@@ -40,7 +40,7 @@ func (b definitionBuilder) addModel(st reflect.Type, nameOverride string) *spec.
st = st.Elem()
}
modelName := b.keyFrom(st)
modelName := keyFrom(st, b.Config)
if nameOverride != "" {
modelName = nameOverride
}
@@ -165,7 +165,7 @@ func (b definitionBuilder) buildProperty(field reflect.StructField, model *spec.
prop.Type = []string{pType}
}
if prop.Format == "" {
prop.Format = b.jsonSchemaFormat(b.keyFrom(fieldType))
prop.Format = b.jsonSchemaFormat(keyFrom(fieldType, b.Config))
}
return jsonName, modelDescription, prop
}
@@ -200,17 +200,18 @@ func (b definitionBuilder) buildProperty(field reflect.StructField, model *spec.
return jsonName, modelDescription, prop
}
fieldTypeName := b.keyFrom(fieldType)
fieldTypeName := keyFrom(fieldType, b.Config)
if b.isPrimitiveType(fieldTypeName) {
mapped := b.jsonSchemaType(fieldTypeName)
prop.Type = []string{mapped}
prop.Format = b.jsonSchemaFormat(fieldTypeName)
return jsonName, modelDescription, prop
}
modelType := b.keyFrom(fieldType)
modelType := keyFrom(fieldType, b.Config)
prop.Ref = spec.MustCreateRef("#/definitions/" + modelType)
if fieldType.Name() == "" { // override type of anonymous structs
// FIXME: Still need a way to handle anonymous struct model naming.
nestedTypeName := modelName + "." + jsonName
prop.Ref = spec.MustCreateRef("#/definitions/" + nestedTypeName)
b.addModel(fieldType, nestedTypeName)
@@ -237,6 +238,7 @@ func (b definitionBuilder) buildStructTypeProperty(field reflect.StructField, js
// check for anonymous
if len(fieldType.Name()) == 0 {
// anonymous
// FIXME: Still need a way to handle anonymous struct model naming.
anonType := model.ID + "." + jsonName
b.addModel(fieldType, anonType)
prop.Ref = spec.MustCreateRef("#/definitions/" + anonType)
@@ -247,7 +249,7 @@ func (b definitionBuilder) buildStructTypeProperty(field reflect.StructField, js
// embedded struct
sub := definitionBuilder{make(spec.Definitions), b.Config}
sub.addModel(fieldType, "")
subKey := sub.keyFrom(fieldType)
subKey := keyFrom(fieldType, b.Config)
// merge properties from sub
subModel, _ := sub.Definitions[subKey]
for k, v := range subModel.Properties {
@@ -277,7 +279,7 @@ func (b definitionBuilder) buildStructTypeProperty(field reflect.StructField, js
}
// simple struct
b.addModel(fieldType, "")
var pType = b.keyFrom(fieldType)
var pType = keyFrom(fieldType, b.Config)
prop.Ref = spec.MustCreateRef("#/definitions/" + pType)
return jsonName, prop
}
@@ -370,7 +372,7 @@ func (b definitionBuilder) buildPointerTypeProperty(field reflect.StructField, j
}
} else {
// non-array, pointer type
fieldTypeName := b.keyFrom(fieldType.Elem())
fieldTypeName := keyFrom(fieldType.Elem(), b.Config)
var pType = b.jsonSchemaType(fieldTypeName) // no star, include pkg path
if b.isPrimitiveType(fieldTypeName) {
prop.Type = []string{pType}
@@ -395,13 +397,13 @@ func (b definitionBuilder) getElementTypeName(modelName, jsonName string, t refl
if t.Name() == "" {
return modelName + "." + jsonName
}
return b.keyFrom(t)
return keyFrom(t, b.Config)
}
func (b definitionBuilder) keyFrom(st reflect.Type) string {
func keyFrom(st reflect.Type, cfg Config) string {
key := st.String()
if b.Config.ModelTypeNameHandler != nil {
if name, ok := b.Config.ModelTypeNameHandler(st); ok {
if cfg.ModelTypeNameHandler != nil {
if name, ok := cfg.ModelTypeNameHandler(st); ok {
key = name
}
}