func (m Scope) MarshalJSON() ([]byte, error) {
	var b1, b2, b3 []byte
	var err error
	b1, err = json.Marshal(struct {
		Actions []string `json:"actions"`
		AuthTokens *ScopeAuthTokens `json:"authTokens"`
		DocAttrPath string `json:"docAttrPath,omitempty"`
		DocID *string `json:"docID"`
		VaultID string `json:"vaultID,omitempty"`
	}{
		Actions: m.Actions,
		AuthTokens: m.AuthTokens,
		DocAttrPath: m.DocAttrPath,
		DocID: m.DocID,
		VaultID: m.VaultID,
	})
	if err != nil {
		return nil, err
	}
	b2, err = json.Marshal(struct {
		Caveats []Caveat `json:"caveats"`
	}{
		Caveats: m.caveatsField,
	})
	if err != nil {
		return nil, err
	}
	return swag.ConcatJSON(b1, b2, b3), nil
}
MarshalJSON marshals this object with a polymorphic type to a JSON structure
package models
import (
	"bytes"
	"context"
	"encoding/json"
	"io"
	"strconv"
	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)
type Scope struct {
	Actions []string `json:"actions"`
	AuthTokens *ScopeAuthTokens `json:"authTokens"`
	caveatsField []Caveat
	DocAttrPath string `json:"docAttrPath,omitempty"`
	DocID *string `json:"docID"`
	VaultID string `json:"vaultID,omitempty"`
}
func (m *Scope) Caveats() []Caveat {
	return m.caveatsField
}
func (m *Scope) SetCaveats(val []Caveat) {
	m.caveatsField = val
}
func (m *Scope) UnmarshalJSON(raw []byte) error {
	var data struct {
		Actions []string `json:"actions"`
		AuthTokens *ScopeAuthTokens `json:"authTokens"`
		Caveats json.RawMessage `json:"caveats"`
		DocAttrPath string `json:"docAttrPath,omitempty"`
		DocID *string `json:"docID"`
		VaultID string `json:"vaultID,omitempty"`
	}
	buf := bytes.NewBuffer(raw)
	dec := json.NewDecoder(buf)
	dec.UseNumber()
	if err := dec.Decode(&data); err != nil {
		return err
	}
	var propCaveats []Caveat
	if string(data.Caveats) != "null" {
		caveats, err := UnmarshalCaveatSlice(bytes.NewBuffer(data.Caveats), runtime.JSONConsumer())
		if err != nil && err != io.EOF {
			return err
		}
		propCaveats = caveats
	}
	var result Scope
	result.Actions = data.Actions
	result.AuthTokens = data.AuthTokens
	result.caveatsField = propCaveats
	result.DocAttrPath = data.DocAttrPath
	result.DocID = data.DocID
	result.VaultID = data.VaultID
	*m = result
	return nil
}