// Package openapi provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.13.0 DO NOT EDIT.
package openapi

import (
	"bytes"
	"compress/gzip"
	"encoding/base64"
	"encoding/json"
	"fmt"
	"net/url"
	"path"
	"strings"
	"time"

	"github.com/deepmap/oapi-codegen/pkg/runtime"
	openapi_types "github.com/deepmap/oapi-codegen/pkg/types"
	"github.com/getkin/kin-openapi/openapi3"
)

// Actor defines model for actor.
type Actor struct {
	Context           Actor_Context  `json:"@context"`
	Icon              ActorIcon      `json:"icon"`
	Id                string         `json:"id"`
	Inbox             string         `json:"inbox"`
	Name              string         `json:"name"`
	Outbox            string         `json:"outbox"`
	PreferredUsername string         `json:"preferredUsername"`
	PublicKey         ActorPublicKey `json:"publicKey"`
	Summary           string         `json:"summary"`
	Type              string         `json:"type"`
}

// ActorContext0 defines model for .
type ActorContext0 = string

// ActorContext1 defines model for .
type ActorContext1 = []string

// Actor_Context defines model for Actor.Context.
type Actor_Context struct {
	union json.RawMessage
}

// ActorIcon defines model for actor-icon.
type ActorIcon struct {
	Type string `json:"type"`
	Url  string `json:"url"`
}

// ActorPublicKey defines model for actor-publicKey.
type ActorPublicKey struct {
	Id           string `json:"id"`
	Owner        string `json:"owner"`
	PublicKeyPem string `json:"publicKeyPem"`
	Type         string `json:"type"`
}

// ApIdentifier defines model for ap-identifier.
type ApIdentifier struct {
	Host          string `json:"host"`
	LocalUsername string `json:"local_username"`
	PublicKey     string `json:"public_key"`
}

// Article defines model for article.
type Article struct {
	Content   string     `json:"content"`
	CreatedAt time.Time  `json:"created_at"`
	Id        string     `json:"id"`
	Title     string     `json:"title"`
	UpdatedAt time.Time  `json:"updated_at"`
	User      SimpleUser `json:"user"`
}

// ArticleComment defines model for article-comment.
type ArticleComment struct {
	ArticleId string     `json:"article_id"`
	Content   string     `json:"content"`
	CreatedAt time.Time  `json:"created_at"`
	Id        string     `json:"id"`
	UpdatedAt time.Time  `json:"updated_at"`
	User      SimpleUser `json:"user"`
}

// Auth defines model for auth.
type Auth struct {
	Password string `json:"password"`
	Username string `json:"username"`
}

// Error400 defines model for error-400.
type Error400 struct {
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
}

// Error401 defines model for error-401.
type Error401 struct {
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
}

// Error404 defines model for error-404.
type Error404 struct {
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
}

// Error409 defines model for error-409.
type Error409 struct {
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
}

// Error500 defines model for error-500.
type Error500 struct {
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
}

// Found defines model for found.
type Found struct {
	Found bool `json:"found"`
}

// Identifiers defines model for identifiers.
type Identifiers struct {
	Activitypub *ApIdentifier    `json:"activitypub,omitempty"`
	Nostr       *NostrIdentifier `json:"nostr,omitempty"`
}

// NewArticle defines model for new-article.
type NewArticle struct {
	Content string `json:"content"`
	Title   string `json:"title"`
}

// NewReaction defines model for new-reaction.
type NewReaction struct {
	PostId string `json:"post_id"`
	Type   string `json:"type"`
}

// Newfollow defines model for newfollow.
type Newfollow struct {
	TargetId string `json:"target_id"`
}

// Newpost defines model for newpost.
type Newpost struct {
	Content string `json:"content"`
}

// Nodeinfo defines model for nodeinfo.
type Nodeinfo struct {
	Metadata          NodeinfoMetadata `json:"metadata"`
	OpenRegistrations bool             `json:"openRegistrations"`
	Protocols         []string         `json:"protocols"`
	Services          NodeinfoService  `json:"services"`
	Software          NodeinfoSoftware `json:"software"`
	Usage             NodeinfoUsage    `json:"usage"`
	Version           string           `json:"version"`
}

// NodeinfoMetadata defines model for nodeinfo-metadata.
type NodeinfoMetadata = map[string]interface{}

// NodeinfoService defines model for nodeinfo-service.
type NodeinfoService struct {
	Inbound  map[string]interface{} `json:"inbound"`
	Outbound map[string]interface{} `json:"outbound"`
}

// NodeinfoSoftware defines model for nodeinfo-software.
type NodeinfoSoftware struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

// NodeinfoUsage defines model for nodeinfo-usage.
type NodeinfoUsage struct {
	Users NodeinfoUsageUsers `json:"users"`
}

// NodeinfoUsageUsers defines model for nodeinfo-usage-users.
type NodeinfoUsageUsers struct {
	Total int `json:"total"`
}

// NostrIdentifier defines model for nostr-identifier.
type NostrIdentifier struct {
	Npub string `json:"npub"`
}

// NostrRelay defines model for nostr-relay.
type NostrRelay struct {
	CreatedAt time.Time `json:"created_at"`
	Id        string    `json:"id"`
	IsEnable  bool      `json:"is_enable"`
	UpdatedAt time.Time `json:"updated_at"`
	Url       string    `json:"url"`
}

// Post defines model for post.
type Post struct {
	Content   string     `json:"content"`
	CreatedAt time.Time  `json:"created_at"`
	Id        string     `json:"id"`
	UpdatedAt time.Time  `json:"updated_at"`
	User      SimpleUser `json:"user"`
}

// SimpleUser defines model for simple-user.
type SimpleUser struct {
	DisplayName string `json:"display_name"`
	Icon        string `json:"icon"`
	Protocol    string `json:"protocol"`
	Username    string `json:"username"`
}

// User defines model for user.
type User struct {
	CreatedAt     time.Time   `json:"created_at"`
	DisplayName   string      `json:"display_name"`
	FollowCount   int         `json:"follow_count"`
	FollowerCount int         `json:"follower_count"`
	Icon          string      `json:"icon"`
	Id            string      `json:"id"`
	Identifiers   Identifiers `json:"identifiers"`
	PostCount     int         `json:"post_count"`
	Profile       string      `json:"profile"`
	Protocol      string      `json:"protocol"`
	UpdatedAt     time.Time   `json:"updated_at"`
	Username      string      `json:"username"`
}

// WellknownNodeinfo defines model for wellknown-nodeinfo.
type WellknownNodeinfo struct {
	Links []WellknownNodeinfoLink `json:"links"`
}

// WellknownNodeinfoLink defines model for wellknown-nodeinfo-link.
type WellknownNodeinfoLink struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
}

// WellknownWebfinger defines model for wellknown-webfinger.
type WellknownWebfinger struct {
	Links   []WellknownWebfingerLink `json:"links"`
	Subject string                   `json:"subject"`
}

// WellknownWebfingerLink defines model for wellknown-webfinger-link.
type WellknownWebfingerLink struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
	Type string `json:"type"`
}

// Id defines model for id.
type Id = string

// Offset defines model for offset.
type Offset = int

// Username defines model for username.
type Username = string

// Webfinger defines model for webfinger.
type Webfinger = string

// GetWellKnownNostrJsonParams defines parameters for GetWellKnownNostrJson.
type GetWellKnownNostrJsonParams struct {
	Name string `form:"name" json:"name"`
}

// GetWellKnownWebfingerParams defines parameters for GetWellKnownWebfinger.
type GetWellKnownWebfingerParams struct {
	Resource Webfinger `form:"resource" json:"resource"`
}

// PostApiV1ImagesUploadMultipartBody defines parameters for PostApiV1ImagesUpload.
type PostApiV1ImagesUploadMultipartBody struct {
	Image *openapi_types.File `json:"image,omitempty"`
}

// GetApiV1TimelineParams defines parameters for GetApiV1Timeline.
type GetApiV1TimelineParams struct {
	Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"`
}

// GetApiV1UsersIdPostsParams defines parameters for GetApiV1UsersIdPosts.
type GetApiV1UsersIdPostsParams struct {
	Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"`
}

// PostApiV1ArticlesJSONRequestBody defines body for PostApiV1Articles for application/json ContentType.
type PostApiV1ArticlesJSONRequestBody = NewArticle

// PostApiV1AuthLoginJSONRequestBody defines body for PostApiV1AuthLogin for application/json ContentType.
type PostApiV1AuthLoginJSONRequestBody = Auth

// PostApiV1AuthRegisterJSONRequestBody defines body for PostApiV1AuthRegister for application/json ContentType.
type PostApiV1AuthRegisterJSONRequestBody = Auth

// PostApiV1ConfigsNostrRelayJSONRequestBody defines body for PostApiV1ConfigsNostrRelay for application/json ContentType.
type PostApiV1ConfigsNostrRelayJSONRequestBody = NostrRelay

// DeleteApiV1FollowsJSONRequestBody defines body for DeleteApiV1Follows for application/json ContentType.
type DeleteApiV1FollowsJSONRequestBody = Newfollow

// PostApiV1FollowsJSONRequestBody defines body for PostApiV1Follows for application/json ContentType.
type PostApiV1FollowsJSONRequestBody = Newfollow

// PostApiV1ImagesUploadMultipartRequestBody defines body for PostApiV1ImagesUpload for multipart/form-data ContentType.
type PostApiV1ImagesUploadMultipartRequestBody PostApiV1ImagesUploadMultipartBody

// PostApiV1PostsJSONRequestBody defines body for PostApiV1Posts for application/json ContentType.
type PostApiV1PostsJSONRequestBody = Newpost

// PostApiV1ReactionsJSONRequestBody defines body for PostApiV1Reactions for application/json ContentType.
type PostApiV1ReactionsJSONRequestBody = NewReaction

// AsActorContext0 returns the union data inside the Actor_Context as a ActorContext0
func (t Actor_Context) AsActorContext0() (ActorContext0, error) {
	var body ActorContext0
	err := json.Unmarshal(t.union, &body)
	return body, err
}

// FromActorContext0 overwrites any union data inside the Actor_Context as the provided ActorContext0
func (t *Actor_Context) FromActorContext0(v ActorContext0) error {
	b, err := json.Marshal(v)
	t.union = b
	return err
}

// MergeActorContext0 performs a merge with any union data inside the Actor_Context, using the provided ActorContext0
func (t *Actor_Context) MergeActorContext0(v ActorContext0) error {
	b, err := json.Marshal(v)
	if err != nil {
		return err
	}

	merged, err := runtime.JsonMerge(t.union, b)
	t.union = merged
	return err
}

// AsActorContext1 returns the union data inside the Actor_Context as a ActorContext1
func (t Actor_Context) AsActorContext1() (ActorContext1, error) {
	var body ActorContext1
	err := json.Unmarshal(t.union, &body)
	return body, err
}

// FromActorContext1 overwrites any union data inside the Actor_Context as the provided ActorContext1
func (t *Actor_Context) FromActorContext1(v ActorContext1) error {
	b, err := json.Marshal(v)
	t.union = b
	return err
}

// MergeActorContext1 performs a merge with any union data inside the Actor_Context, using the provided ActorContext1
func (t *Actor_Context) MergeActorContext1(v ActorContext1) error {
	b, err := json.Marshal(v)
	if err != nil {
		return err
	}

	merged, err := runtime.JsonMerge(t.union, b)
	t.union = merged
	return err
}

func (t Actor_Context) MarshalJSON() ([]byte, error) {
	b, err := t.union.MarshalJSON()
	return b, err
}

func (t *Actor_Context) UnmarshalJSON(b []byte) error {
	err := t.union.UnmarshalJSON(b)
	return err
}

// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{

	"H4sIAAAAAAAC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zUBU/MTppP3M7nQK0Z2Hx+pUEjPvTPdzpheFn5UN",
	"d/AQT71257JnRcpt+NEl4tPGtYs3V9o1V8IzNAEW5llCUOw+DbiWz73zmXrlyhGd5GOm2raGqFmecJwh",
	"ysMxobOBfgXLdedOgqzcKB/hVH27o3lP1BJn1hvIam8xqbdbSmQ5xX1h1QwohPSU8t52IHbGa5SDVJ0m",
	"IeQuz8JH/S6CO/RcyJbeD1cwIxzCC1Fe/Wg/VNOhR3W5Nj+lsErYKd+P2GjwKd5Hsi+A5eL3ui777fTi",
	"X7wiabK48tJG10V2T72FYaesvsh+uL/Jq+y9LrAfqov8O6T5EnZF+SLMdl+uvCSs5ZLBpRxjY6WgRLaN",
	"QlDI9XZzchdvTirWNolc1l8d5+3SsvZrk8YGoeT12iquow2Qc5sH8vYY971XVlLtuxpctVu0HMa3MF9H",
	"0fXSfn3KWcYBi0leaa73IuhorNL660KthzeiSLkH76po63FiT0CMpfqqHHfz53AFKoXy7TLUG9H9Javd",
	"JyoncdzN6DKlrvJ5M28rlV/62kZuXari7ZjlzZPsnmSEDY5nkOAUWl/F+bdu5EpsjAarZTbFJ8yf57Ub",
	"leZ030Mspdn5oF9+7cr9JluSyIKTeT+MCfViGOWTH512lC2f5Wqo2l7stkWJf/d329QnNGbtrnSaUwop",
	"b98glgL/Bv4WtndNfGbq/2w3s3d7e8Rp9s5XSqVY7eWhNPuzlIfVb7H0f1NH/uWEhfzI+9u5wus9V1hS",
	"PtSfzGqPQme6lUfGPZa+87jssLsv8Va+29cdyLRExosN27+v8cJo1odkK1LseyPYG72eQq/yz+tYyXVS",
	"RMvLfOSd678/00Yt3WgdxDpc/z307LkPNsy/7rCNt9Q/4UmKeE7hRZGyPEB2rngXiANTJw+9lz19pLw6",
	"N4OXWc2bStrawhi+5ZedTrBY/C8AAP//0zGQ0VdvAAA=",
}

// GetSwagger returns the content of the embedded swagger specification file
// or error if failed to decode
func decodeSpec() ([]byte, error) {
	zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
	if err != nil {
		return nil, fmt.Errorf("error base64 decoding spec: %s", err)
	}
	zr, err := gzip.NewReader(bytes.NewReader(zipped))
	if err != nil {
		return nil, fmt.Errorf("error decompressing spec: %s", err)
	}
	var buf bytes.Buffer
	_, err = buf.ReadFrom(zr)
	if err != nil {
		return nil, fmt.Errorf("error decompressing spec: %s", err)
	}

	return buf.Bytes(), nil
}

var rawSpec = decodeSpecCached()

// a naive cached of a decoded swagger spec
func decodeSpecCached() func() ([]byte, error) {
	data, err := decodeSpec()
	return func() ([]byte, error) {
		return data, err
	}
}

// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
	var res = make(map[string]func() ([]byte, error))
	if len(pathToFile) > 0 {
		res[pathToFile] = rawSpec
	}

	return res
}

// GetSwagger returns the Swagger specification corresponding to the generated code
// in this file. The external references of Swagger specification are resolved.
// The logic of resolving external references is tightly connected to "import-mapping" feature.
// Externally referenced files must be embedded in the corresponding golang packages.
// Urls can be supported but this task was out of the scope.
func GetSwagger() (swagger *openapi3.T, err error) {
	var resolvePath = PathToRawSpec("")

	loader := openapi3.NewLoader()
	loader.IsExternalRefsAllowed = true
	loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
		var pathToFile = url.String()
		pathToFile = path.Clean(pathToFile)
		getSpec, ok := resolvePath[pathToFile]
		if !ok {
			err1 := fmt.Errorf("path not found: %s", pathToFile)
			return nil, err1
		}
		return getSpec()
	}
	var specData []byte
	specData, err = rawSpec()
	if err != nil {
		return
	}
	swagger, err = loader.LoadFromData(specData)
	if err != nil {
		return
	}
	return
}
