func (m RefQuery) MarshalJSON() ([]byte, error) {
	var b1, b2, b3 []byte
	var err error
	b1, err = json.Marshal(struct {
		Ref *string `json:"ref"`
	}{
		Ref: m.Ref,
	})
	if err != nil {
		return nil, err
	}
	b2, err = json.Marshal(struct {
		ID string `json:"id,omitempty"`
		Type string `json:"type"`
	}{
		ID: m.ID(),
		Type: m.Type(),
	})
	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"
	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)
type RefQuery struct {
	idField string
	Ref *string `json:"ref"`
}
func (m *RefQuery) ID() string {
	return m.idField
}
func (m *RefQuery) SetID(val string) {
	m.idField = val
}
func (m *RefQuery) Type() string {
	return "RefQuery"
}
func (m *RefQuery) SetType(val string) {
}
func (m *RefQuery) UnmarshalJSON(raw []byte) error {
	var data struct {
		Ref *string `json:"ref"`
	}
	buf := bytes.NewBuffer(raw)
	dec := json.NewDecoder(buf)
	dec.UseNumber()
	if err := dec.Decode(&data); err != nil {
		return err
	}
	var base struct {
		ID string `json:"id,omitempty"`
		Type string `json:"type"`
	}
	buf = bytes.NewBuffer(raw)
	dec = json.NewDecoder(buf)
	dec.UseNumber()
	if err := dec.Decode(&base); err != nil {
		return err
	}
	var result RefQuery
	result.idField = base.ID
	if base.Type != result.Type() {
		return errors.New(422, "invalid type value: %q", base.Type)
	}
	result.Ref = data.Ref
	*m = result
	return nil
}