func requestBody(n *gen.Type, op string) (*spec.RequestBody, error) {
	req := &spec.RequestBody{}
	switch op {
	case opCreate:
		req.Description = fmt.Sprintf("%s to create", n.Name)
	case opUpdate:
		req.Description = fmt.Sprintf("%s properties to update", n.Name)
	default:
		return nil, fmt.Errorf("requestBody: unsupported operation %q", op)
	}
	fs := make(spec.Fields)
	for _, f := range n.Fields {
		if op == opCreate || !f.Immutable {
			sf, err := newField(f)
			if err != nil {
				return nil, err
			}
			fs[f.Name] = sf
		}
	}
	for _, e := range n.Edges {
		t, err := oasType(e.Type.ID)
		if err != nil {
			return nil, err
		}
		fs[e.Name] = &spec.Field{
			Unique:   e.Unique,
			Required: !e.Optional,
			Type:     *t,
			Example:  nil, // TODO: Example for a unique / non-unique edge
		}
	}
	req.Content = spec.Content{
		spec.JSON: spec.MediaTypeObject{
			Unique: true,
			Schema: spec.Schema{
				Name:   fmt.Sprintf("%s%sRequest", n.Name, strcase.UpperCamelCase(op)),
				Fields: fs,
			},
		},
	}
	return req, nil
}
// requestBody returns the request-body to use for the given node and operation.
requestBody returns the request-body to use for the given node and operation.
// requestBody returns the request - body to use for the given node and operation .
func requestBody(n *gen.Type, op string) (*spec.RequestBody, error) {
	req := &spec.RequestBody{}
	switch op {
	case opCreate:
		req.Description = fmt.Sprintf("%s to create", n.Name)
	case opUpdate:
		req.Description = fmt.Sprintf("%s properties to update", n.Name)
	default:
		return nil, fmt.Errorf("requestBody: unsupported operation %q", op)
	}
	fs := make(spec.Fields)
	for _, f := range n.Fields {
		if op == opCreate || !f.Immutable {
			sf, err := newField(f)
			if err != nil {
				return nil, err
			}
			fs[f.Name] = sf
		}
	}
	for _, e := range n.Edges {
		t, err := oasType(e.Type.ID)
		if err != nil {
			return nil, err
		}
		fs[e.Name] = &spec.Field{
			Unique:   e.Unique,
			Required: !e.Optional,
			Type:     *t,
			Example:  nil, 
		}
	}
	req.Content = spec.Content{
		spec.JSON: spec.MediaTypeObject{
			Unique: true,
			Schema: spec.Schema{
				Name:   fmt.Sprintf("%s%sRequest", n.Name, strcase.UpperCamelCase(op)),
				Fields: fs,
			},
		},
	}
	return req, nil
}
func requestBody ( n * gen . Type , op string ) ( * spec . RequestBody , error ) { req := & spec . RequestBody { } switch op { case opCreate : req . Description = fmt . Sprintf ( " " , n . Name ) case opUpdate : req . Description = fmt . Sprintf ( " " , n . Name ) default : return nil , fmt . Errorf ( " " , op ) } fs := make ( spec . Fields ) for _ , f := range n . Fields { if op == opCreate || ! f . Immutable { sf , err := newField ( f ) if err != nil { return nil , err } fs [ f . Name ] = sf } } for _ , e := range n . Edges { t , err := oasType ( e . Type . ID ) if err != nil { return nil , err } fs [ e . Name ] = & spec . Field { Unique : e . Unique , Required : ! e . Optional , Type : * t , Example : nil , } } req . Content = spec . Content { spec . JSON : spec . MediaTypeObject { Unique : true , Schema : spec . Schema { Name : fmt . Sprintf ( " " , n . Name , strcase . UpperCamelCase ( op ) ) , Fields : fs , } , } , } return req , nil }
requestBody returns the request-body to use for the given node and operation.
requestBody returns the request - body to use for the given node and operation .
// TODO: Example for a unique / non-unique edge