mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 08:52:25 -05:00 
			
		
		
		
	* Add Swagger spec test script * Fix Swagger spec errors not related to statuses with polls * Add API tests that post a status with a poll * Fix creating a status with a poll from form params * Fix Swagger spec errors related to statuses with polls (this is the last error) * Fix Swagger spec warnings not related to unused definitions * Suppress a duplicate list update params definition that was somehow causing wrong param names * Add Swagger test to CI - updates Drone config - vendorizes go-swagger - fixes a file extension issue that caused the test script to generate JSON instead of YAML with the vendorized version * Put `Sample: ` on its own line everywhere * Remove unused id param from emojiCategoriesGet * Add 5 more pairs of profile fields to account update API Swagger * Remove Swagger prefix from dummy fields It makes the generated code look weird * Manually annotate params for statusCreate operation * Fix all remaining Swagger spec warnings - Change some models into operation parameters - Ignore models that already correspond to manually documented operation parameters but can't be trivially changed (those with file fields) * Documented that creating a status with scheduled_at isn't implemented yet * sign drone.yml * Fix filter API Swagger errors * fixup! Fix filter API Swagger errors --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
		
			
				
	
	
		
			138 lines
		
	
	
	
		
			3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			138 lines
		
	
	
	
		
			3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package flags
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| )
 | |
| 
 | |
| // ErrorType represents the type of error.
 | |
| type ErrorType uint
 | |
| 
 | |
| const (
 | |
| 	// ErrUnknown indicates a generic error.
 | |
| 	ErrUnknown ErrorType = iota
 | |
| 
 | |
| 	// ErrExpectedArgument indicates that an argument was expected.
 | |
| 	ErrExpectedArgument
 | |
| 
 | |
| 	// ErrUnknownFlag indicates an unknown flag.
 | |
| 	ErrUnknownFlag
 | |
| 
 | |
| 	// ErrUnknownGroup indicates an unknown group.
 | |
| 	ErrUnknownGroup
 | |
| 
 | |
| 	// ErrMarshal indicates a marshalling error while converting values.
 | |
| 	ErrMarshal
 | |
| 
 | |
| 	// ErrHelp indicates that the built-in help was shown (the error
 | |
| 	// contains the help message).
 | |
| 	ErrHelp
 | |
| 
 | |
| 	// ErrNoArgumentForBool indicates that an argument was given for a
 | |
| 	// boolean flag (which don't not take any arguments).
 | |
| 	ErrNoArgumentForBool
 | |
| 
 | |
| 	// ErrRequired indicates that a required flag was not provided.
 | |
| 	ErrRequired
 | |
| 
 | |
| 	// ErrShortNameTooLong indicates that a short flag name was specified,
 | |
| 	// longer than one character.
 | |
| 	ErrShortNameTooLong
 | |
| 
 | |
| 	// ErrDuplicatedFlag indicates that a short or long flag has been
 | |
| 	// defined more than once
 | |
| 	ErrDuplicatedFlag
 | |
| 
 | |
| 	// ErrTag indicates an error while parsing flag tags.
 | |
| 	ErrTag
 | |
| 
 | |
| 	// ErrCommandRequired indicates that a command was required but not
 | |
| 	// specified
 | |
| 	ErrCommandRequired
 | |
| 
 | |
| 	// ErrUnknownCommand indicates that an unknown command was specified.
 | |
| 	ErrUnknownCommand
 | |
| 
 | |
| 	// ErrInvalidChoice indicates an invalid option value which only allows
 | |
| 	// a certain number of choices.
 | |
| 	ErrInvalidChoice
 | |
| 
 | |
| 	// ErrInvalidTag indicates an invalid tag or invalid use of an existing tag
 | |
| 	ErrInvalidTag
 | |
| )
 | |
| 
 | |
| func (e ErrorType) String() string {
 | |
| 	switch e {
 | |
| 	case ErrUnknown:
 | |
| 		return "unknown"
 | |
| 	case ErrExpectedArgument:
 | |
| 		return "expected argument"
 | |
| 	case ErrUnknownFlag:
 | |
| 		return "unknown flag"
 | |
| 	case ErrUnknownGroup:
 | |
| 		return "unknown group"
 | |
| 	case ErrMarshal:
 | |
| 		return "marshal"
 | |
| 	case ErrHelp:
 | |
| 		return "help"
 | |
| 	case ErrNoArgumentForBool:
 | |
| 		return "no argument for bool"
 | |
| 	case ErrRequired:
 | |
| 		return "required"
 | |
| 	case ErrShortNameTooLong:
 | |
| 		return "short name too long"
 | |
| 	case ErrDuplicatedFlag:
 | |
| 		return "duplicated flag"
 | |
| 	case ErrTag:
 | |
| 		return "tag"
 | |
| 	case ErrCommandRequired:
 | |
| 		return "command required"
 | |
| 	case ErrUnknownCommand:
 | |
| 		return "unknown command"
 | |
| 	case ErrInvalidChoice:
 | |
| 		return "invalid choice"
 | |
| 	case ErrInvalidTag:
 | |
| 		return "invalid tag"
 | |
| 	}
 | |
| 
 | |
| 	return "unrecognized error type"
 | |
| }
 | |
| 
 | |
| func (e ErrorType) Error() string {
 | |
| 	return e.String()
 | |
| }
 | |
| 
 | |
| // Error represents a parser error. The error returned from Parse is of this
 | |
| // type. The error contains both a Type and Message.
 | |
| type Error struct {
 | |
| 	// The type of error
 | |
| 	Type ErrorType
 | |
| 
 | |
| 	// The error message
 | |
| 	Message string
 | |
| }
 | |
| 
 | |
| // Error returns the error's message
 | |
| func (e *Error) Error() string {
 | |
| 	return e.Message
 | |
| }
 | |
| 
 | |
| func newError(tp ErrorType, message string) *Error {
 | |
| 	return &Error{
 | |
| 		Type:    tp,
 | |
| 		Message: message,
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func newErrorf(tp ErrorType, format string, args ...interface{}) *Error {
 | |
| 	return newError(tp, fmt.Sprintf(format, args...))
 | |
| }
 | |
| 
 | |
| func wrapError(err error) *Error {
 | |
| 	ret, ok := err.(*Error)
 | |
| 
 | |
| 	if !ok {
 | |
| 		return newError(ErrUnknown, err.Error())
 | |
| 	}
 | |
| 
 | |
| 	return ret
 | |
| }
 |