Skip to content

Commit

Permalink
Fix expansions to be nested under oneOf
Browse files Browse the repository at this point in the history
  • Loading branch information
brandur committed Jun 23, 2017
1 parent 0bdbfc5 commit e7b8e14
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion generator.go
Expand Up @@ -99,7 +99,7 @@ func (g *DataGenerator) generateInternal(schema *JSONSchema, requestPath string,
var ok bool
subExpansions, ok = expansions.expansions[key]
if ok {
subSchema = property.XExpansionResources[0]
subSchema = property.XExpansionResources.OneOf[0]
}
}

Expand Down
6 changes: 4 additions & 2 deletions main_test.go
Expand Up @@ -31,8 +31,10 @@ func init() {
// customer resource
"customer": {
Type: []string{"string"},
XExpansionResources: []*JSONSchema{
&JSONSchema{Ref: "#/definitions/customer"},
XExpansionResources: &JSONSchema{
OneOf: []*JSONSchema{
&JSONSchema{Ref: "#/definitions/customer"},
},
},
},
},
Expand Down
7 changes: 4 additions & 3 deletions spec.go
Expand Up @@ -9,16 +9,17 @@ type HTTPVerb string
type JSONSchema struct {
Enum []string `json:"enum"`
Items *JSONSchema `json:"items"`
OneOf []*JSONSchema `json:"oneOf"`
Properties map[string]*JSONSchema `json:"properties"`
Type []string `json:"type"`

// Ref is populated if this JSON Schema is actually a JSON reference, and
// it defines the location of the actual schema definition.
Ref string `json:"$ref"`

XExpandableFields []string `json:"x-expandableFields"`
XExpansionResources []*JSONSchema `json:"x-expansionResources"`
XResourceID string `json:"x-resourceId"`
XExpandableFields []string `json:"x-expandableFields"`
XExpansionResources *JSONSchema `json:"x-expansionResources"`
XResourceID string `json:"x-resourceId"`
}

type OpenAPIParameter struct {
Expand Down

0 comments on commit e7b8e14

Please sign in to comment.