这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ type hcontext struct {
func (c *hcontext) WithValue(key, value interface{}) Context {
r := c.r.WithContext(context.WithValue(c.r.Context(), key, value))
return &hcontext{
Context: context.WithValue(c.Context, key, value),
ResponseWriter: c.ResponseWriter,
r: r,
errors: append([]error{}, c.errors...),
op: c.op,
closed: c.closed,
Context: context.WithValue(c.Context, key, value),
ResponseWriter: c.ResponseWriter,
r: r,
errors: append([]error{}, c.errors...),
op: c.op,
closed: c.closed,
disableSchemaProperty: c.disableSchemaProperty,
}
}

Expand Down
10 changes: 5 additions & 5 deletions openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ type oaComponents struct {
}

// AddSchema creates and adds a new schema from a type.
func (c *oaComponents) AddSchema(t reflect.Type, mode schema.Mode, hint string) string {
return c.addSchema(t, mode, hint, true)
func (c *oaComponents) AddSchema(t reflect.Type, mode schema.Mode, hint string, generateSchemaField bool) string {
return c.addSchema(t, mode, hint, generateSchemaField)
}

func (c *oaComponents) addSchema(t reflect.Type, mode schema.Mode, hint string, generateSchemaField bool) string {
Expand Down Expand Up @@ -103,9 +103,9 @@ func (c *oaComponents) addSchema(t reflect.Type, mode schema.Mode, hint string,
return c.addExistingSchema(s, name, generateSchemaField)
}

// AddExistingSchema adds an existing schema instance under the given name.
func (c *oaComponents) AddExistingSchema(s *schema.Schema, name string) string {
return c.addExistingSchema(s, name, true)
//AddExistingSchema adds an existing schema instance under the given name.
func (c *oaComponents) AddExistingSchema(s *schema.Schema, name string, generateSchemaField bool) string {
return c.addExistingSchema(s, name, generateSchemaField)
}

func (c *oaComponents) addExistingSchema(s *schema.Schema, name string, generateSchemaField bool) string {
Expand Down
6 changes: 3 additions & 3 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ func (o *Operation) toOpenAPI(components *oaComponents) *gabs.Container {
}
ref := ""
if o.requestSchemaOverride {
ref = components.AddExistingSchema(o.requestSchema, o.id+"-request")
ref = components.AddExistingSchema(o.requestSchema, o.id+"-request", !o.resource.router.disableSchemaProperty)
} else {
// Regenerate with ModeAll so the same model can be used for both the
// input and output when possible.
ref = components.AddSchema(o.requestModel, schema.ModeAll, o.id+"-request")
ref = components.AddSchema(o.requestModel, schema.ModeAll, o.id+"-request", !o.resource.router.disableSchemaProperty)
}
doc.Set(ref, "requestBody", "content", ct, "schema", "$ref")
}
Expand Down Expand Up @@ -136,7 +136,7 @@ func (o *Operation) toOpenAPI(components *oaComponents) *gabs.Container {
}

if resp.model != nil {
ref := components.AddSchema(resp.model, schema.ModeAll, o.id+"-response")
ref := components.AddSchema(resp.model, schema.ModeAll, o.id+"-response", !o.resource.router.disableSchemaProperty)
o.responses[i].modelRef = ref
doc.Set(ref, "responses", status, "content", resp.contentType, "schema", "$ref")
}
Expand Down