Skip to content

Latest commit

 

History

History
387 lines (340 loc) · 14.1 KB

examples.md

File metadata and controls

387 lines (340 loc) · 14.1 KB

a.json

schemarshal -p sample test_data/a.json
// Code generated by schemarshal 1.3.0 `schemarshal -p sample test_data/a.json`
// DO NOT RECOMMEND EDITING THIS FILE.

package sample

import (
	"fmt"
	"strconv"
	"time"
)

type AAddressObject struct {
	City          *string `json:"city"`
	StreetAddress string  `json:"streetAddress"`
}

type APhoneNumberFugaObject map[string]interface{}

type APhoneNumberHogeObject struct {
	Aaa bool                    `json:"aaa,omitempty"`
	Bbb APhoneNumberHogeBbbEnum `json:"bbb,omitempty"`
}

type APhoneNumberItem struct {
	Code     int64                  `json:"code"`
	Fuga     map[string]interface{} `json:"fuga,omitempty"`
	Hoge     APhoneNumberHogeObject `json:"hoge,omitempty"`
	Location string                 `json:"location"`
}

type ATest3Item struct {
	Hoge string `json:"hoge"`
}

type A struct {
	Address     AAddressObject     `json:"address"`
	PhoneNumber []APhoneNumberItem `json:"phoneNumber"`
	Test        []int64            `json:"test,omitempty"`
	Test2       time.Time          `json:"test2,omitempty"`
	Test3       []ATest3Item       `json:"test3,omitempty"`
}

type APhoneNumberHogeBbbEnum int

const (
	APhoneNumberHogeBbbEnum2 APhoneNumberHogeBbbEnum = iota
	APhoneNumberHogeBbbEnum4
	APhoneNumberHogeBbbEnum6
)

var _aPhoneNumberHogeBbbEnum = map[APhoneNumberHogeBbbEnum]interface{}{
	APhoneNumberHogeBbbEnum2: 2,
	APhoneNumberHogeBbbEnum4: 4,
	APhoneNumberHogeBbbEnum6: 6,
}

func (enum APhoneNumberHogeBbbEnum) MarshalJSON() ([]byte, error) {
	switch v := _aPhoneNumberHogeBbbEnum[enum].(type) {
	case string:
		return []byte(strconv.Quote(v)), nil
	default:
		return []byte(fmt.Sprintf("%v", v)), nil
	}
}

func (enum *APhoneNumberHogeBbbEnum) UnmarshalJSON(data []byte) error {
	for i, v := range _aPhoneNumberHogeBbbEnum {
		switch vv := v.(type) {
		case string:
			if strconv.Quote(vv) == string(data) {
				*enum = APhoneNumberHogeBbbEnum(i)
				return nil
			}
		default:
			if fmt.Sprintf("%v", v) == string(data) {
				*enum = APhoneNumberHogeBbbEnum(i)
				return nil
			}
		}
	}
	return fmt.Errorf("Error: miss-matched APhoneNumberHogeBbbEnum (%s)", data)
}

func (enum APhoneNumberHogeBbbEnum) String() string {
	switch v := _aPhoneNumberHogeBbbEnum[enum].(type) {
	case string:
		return v
	default:
		return fmt.Sprintf("%v", v)
	}
}

func ToAPhoneNumberHogeBbbEnum(val interface{}) *APhoneNumberHogeBbbEnum {
	for i, v := range _aPhoneNumberHogeBbbEnum {
		if val == v {
			return &i
		}
	}
	return nil
}

qiita-v2-schema

curl -s "https://qiita.com/api/v2/schema" | schemarshal -nc
// Code generated by schemarshal 1.3.0 `schemarshal -nc`
// DO NOT RECOMMEND EDITING THIS FILE.

package main

import "time"

type QiitaAPIV2JSONSchemaAccessTokenObject struct {
	ClientID string   `json:"client_id"`
	Scopes   []string `json:"scopes"`
	Token    string   `json:"token"`
}

type QiitaAPIV2JSONSchemaAuthenticatedUserObject struct {
	Description                 *string `json:"description"`
	FacebookID                  *string `json:"facebook_id"`
	FolloweesCount              int64   `json:"followees_count"`
	FollowersCount              int64   `json:"followers_count"`
	GithubLoginName             *string `json:"github_login_name"`
	ID                          string  `json:"id"`
	ImageMonthlyUploadLimit     int64   `json:"image_monthly_upload_limit"`
	ImageMonthlyUploadRemaining int64   `json:"image_monthly_upload_remaining"`
	ItemsCount                  int64   `json:"items_count"`
	LinkedinID                  *string `json:"linkedin_id"`
	Location                    *string `json:"location"`
	Name                        *string `json:"name"`
	Organization                *string `json:"organization"`
	PermanentID                 int64   `json:"permanent_id"`
	ProfileImageURL             string  `json:"profile_image_url"`
	TeamOnly                    bool    `json:"team_only"`
	TwitterScreenName           *string `json:"twitter_screen_name"`
	WebsiteURL                  *string `json:"website_url"`
}

type QiitaAPIV2JSONSchemaCommentUserObject struct {
	Description       *string `json:"description"`
	FacebookID        *string `json:"facebook_id"`
	FolloweesCount    int64   `json:"followees_count"`
	FollowersCount    int64   `json:"followers_count"`
	GithubLoginName   *string `json:"github_login_name"`
	ID                string  `json:"id"`
	ItemsCount        int64   `json:"items_count"`
	LinkedinID        *string `json:"linkedin_id"`
	Location          *string `json:"location"`
	Name              *string `json:"name"`
	Organization      *string `json:"organization"`
	PermanentID       int64   `json:"permanent_id"`
	ProfileImageURL   string  `json:"profile_image_url"`
	TwitterScreenName *string `json:"twitter_screen_name"`
	WebsiteURL        *string `json:"website_url"`
}

type QiitaAPIV2JSONSchemaCommentObject struct {
	Body         string                                `json:"body"`
	CreatedAt    time.Time                             `json:"created_at"`
	ID           string                                `json:"id"`
	RenderedBody string                                `json:"rendered_body"`
	UpdatedAt    time.Time                             `json:"updated_at"`
	User         QiitaAPIV2JSONSchemaCommentUserObject `json:"user"`
}

type QiitaAPIV2JSONSchemaExpandedTemplateExpandedTagsItem struct {
	Name     string   `json:"name"`
	Versions []string `json:"versions,omitempty"`
}

type QiitaAPIV2JSONSchemaExpandedTemplateObject struct {
	ExpandedBody  string                                                 `json:"expanded_body"`
	ExpandedTags  []QiitaAPIV2JSONSchemaExpandedTemplateExpandedTagsItem `json:"expanded_tags"`
	ExpandedTitle string                                                 `json:"expanded_title"`
}

type QiitaAPIV2JSONSchemaGroupObject struct {
	CreatedAt time.Time `json:"created_at"`
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	Private   bool      `json:"private"`
	UpdatedAt time.Time `json:"updated_at"`
	URLName   string    `json:"url_name"`
}

type QiitaAPIV2JSONSchemaItemGroupObject struct {
	CreatedAt time.Time `json:"created_at"`
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	Private   bool      `json:"private"`
	UpdatedAt time.Time `json:"updated_at"`
	URLName   string    `json:"url_name"`
}

type QiitaAPIV2JSONSchemaItemTagsItem struct {
	Name     string   `json:"name"`
	Versions []string `json:"versions,omitempty"`
}

type QiitaAPIV2JSONSchemaItemUserObject struct {
	Description       *string `json:"description"`
	FacebookID        *string `json:"facebook_id"`
	FolloweesCount    int64   `json:"followees_count"`
	FollowersCount    int64   `json:"followers_count"`
	GithubLoginName   *string `json:"github_login_name"`
	ID                string  `json:"id"`
	ItemsCount        int64   `json:"items_count"`
	LinkedinID        *string `json:"linkedin_id"`
	Location          *string `json:"location"`
	Name              *string `json:"name"`
	Organization      *string `json:"organization"`
	PermanentID       int64   `json:"permanent_id"`
	ProfileImageURL   string  `json:"profile_image_url"`
	TwitterScreenName *string `json:"twitter_screen_name"`
	WebsiteURL        *string `json:"website_url"`
}

type QiitaAPIV2JSONSchemaItemObject struct {
	Body           string                              `json:"body"`
	Coediting      bool                                `json:"coediting"`
	CommentsCount  int64                               `json:"comments_count"`
	CreatedAt      time.Time                           `json:"created_at"`
	Group          QiitaAPIV2JSONSchemaItemGroupObject `json:"group"`
	ID             string                              `json:"id"`
	LikesCount     int64                               `json:"likes_count"`
	PageViewsCount *int64                              `json:"page_views_count"`
	Private        bool                                `json:"private"`
	ReactionsCount int64                               `json:"reactions_count"`
	RenderedBody   string                              `json:"rendered_body"`
	Tags           []QiitaAPIV2JSONSchemaItemTagsItem  `json:"tags"`
	Title          string                              `json:"title"`
	UpdatedAt      time.Time                           `json:"updated_at"`
	URL            string                              `json:"url"`
	User           QiitaAPIV2JSONSchemaItemUserObject  `json:"user"`
}

type QiitaAPIV2JSONSchemaLikeUserObject struct {
	Description       *string `json:"description"`
	FacebookID        *string `json:"facebook_id"`
	FolloweesCount    int64   `json:"followees_count"`
	FollowersCount    int64   `json:"followers_count"`
	GithubLoginName   *string `json:"github_login_name"`
	ID                string  `json:"id"`
	ItemsCount        int64   `json:"items_count"`
	LinkedinID        *string `json:"linkedin_id"`
	Location          *string `json:"location"`
	Name              *string `json:"name"`
	Organization      *string `json:"organization"`
	PermanentID       int64   `json:"permanent_id"`
	ProfileImageURL   string  `json:"profile_image_url"`
	TwitterScreenName *string `json:"twitter_screen_name"`
	WebsiteURL        *string `json:"website_url"`
}

type QiitaAPIV2JSONSchemaLikeObject struct {
	CreatedAt time.Time                          `json:"created_at"`
	User      QiitaAPIV2JSONSchemaLikeUserObject `json:"user"`
}

type QiitaAPIV2JSONSchemaProjectObject struct {
	Archived       bool      `json:"archived"`
	Body           string    `json:"body"`
	CreatedAt      time.Time `json:"created_at"`
	ID             int64     `json:"id"`
	Name           string    `json:"name"`
	ReactionsCount int64     `json:"reactions_count"`
	RenderedBody   string    `json:"rendered_body"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type QiitaAPIV2JSONSchemaReactionUserObject struct {
	Description       *string `json:"description"`
	FacebookID        *string `json:"facebook_id"`
	FolloweesCount    int64   `json:"followees_count"`
	FollowersCount    int64   `json:"followers_count"`
	GithubLoginName   *string `json:"github_login_name"`
	ID                string  `json:"id"`
	ItemsCount        int64   `json:"items_count"`
	LinkedinID        *string `json:"linkedin_id"`
	Location          *string `json:"location"`
	Name              *string `json:"name"`
	Organization      *string `json:"organization"`
	PermanentID       int64   `json:"permanent_id"`
	ProfileImageURL   string  `json:"profile_image_url"`
	TwitterScreenName *string `json:"twitter_screen_name"`
	WebsiteURL        *string `json:"website_url"`
}

type QiitaAPIV2JSONSchemaReactionObject struct {
	CreatedAt time.Time                              `json:"created_at"`
	ImageURL  string                                 `json:"image_url"`
	Name      string                                 `json:"name"`
	User      QiitaAPIV2JSONSchemaReactionUserObject `json:"user"`
}

type QiitaAPIV2JSONSchemaTagObject struct {
	FollowersCount int64   `json:"followers_count"`
	IconURL        *string `json:"icon_url"`
	ID             string  `json:"id"`
	ItemsCount     int64   `json:"items_count"`
}

type QiitaAPIV2JSONSchemaTaggingObject struct {
	Name     string   `json:"name"`
	Versions []string `json:"versions"`
}

type QiitaAPIV2JSONSchemaTeamObject struct {
	Active bool   `json:"active"`
	ID     string `json:"id"`
	Name   string `json:"name"`
}

type QiitaAPIV2JSONSchemaTeamInvitationObject struct {
	Email string `json:"email"`
	URL   string `json:"url"`
}

type QiitaAPIV2JSONSchemaTemplateExpandedTagsItem struct {
	Name     string   `json:"name"`
	Versions []string `json:"versions,omitempty"`
}

type QiitaAPIV2JSONSchemaTemplateTagsItem struct {
	Name     string   `json:"name"`
	Versions []string `json:"versions,omitempty"`
}

type QiitaAPIV2JSONSchemaTemplateObject struct {
	Body          string                                         `json:"body"`
	ExpandedBody  string                                         `json:"expanded_body"`
	ExpandedTags  []QiitaAPIV2JSONSchemaTemplateExpandedTagsItem `json:"expanded_tags"`
	ExpandedTitle string                                         `json:"expanded_title"`
	ID            int64                                          `json:"id"`
	Name          string                                         `json:"name"`
	Tags          []QiitaAPIV2JSONSchemaTemplateTagsItem         `json:"tags"`
	Title         string                                         `json:"title"`
}

type QiitaAPIV2JSONSchemaUserObject struct {
	Description       *string `json:"description"`
	FacebookID        *string `json:"facebook_id"`
	FolloweesCount    int64   `json:"followees_count"`
	FollowersCount    int64   `json:"followers_count"`
	GithubLoginName   *string `json:"github_login_name"`
	ID                string  `json:"id"`
	ItemsCount        int64   `json:"items_count"`
	LinkedinID        *string `json:"linkedin_id"`
	Location          *string `json:"location"`
	Name              *string `json:"name"`
	Organization      *string `json:"organization"`
	PermanentID       int64   `json:"permanent_id"`
	ProfileImageURL   string  `json:"profile_image_url"`
	TwitterScreenName *string `json:"twitter_screen_name"`
	WebsiteURL        *string `json:"website_url"`
}

type QiitaAPIV2JSONSchema struct {
	AccessToken       QiitaAPIV2JSONSchemaAccessTokenObject       `json:"access_token"`
	AuthenticatedUser QiitaAPIV2JSONSchemaAuthenticatedUserObject `json:"authenticated_user"`
	Comment           QiitaAPIV2JSONSchemaCommentObject           `json:"comment"`
	ExpandedTemplate  QiitaAPIV2JSONSchemaExpandedTemplateObject  `json:"expanded_template"`
	Group             QiitaAPIV2JSONSchemaGroupObject             `json:"group"`
	Item              QiitaAPIV2JSONSchemaItemObject              `json:"item"`
	Like              QiitaAPIV2JSONSchemaLikeObject              `json:"like"`
	Project           QiitaAPIV2JSONSchemaProjectObject           `json:"project"`
	Reaction          QiitaAPIV2JSONSchemaReactionObject          `json:"reaction"`
	Tag               QiitaAPIV2JSONSchemaTagObject               `json:"tag"`
	Tagging           QiitaAPIV2JSONSchemaTaggingObject           `json:"tagging"`
	Team              QiitaAPIV2JSONSchemaTeamObject              `json:"team"`
	TeamInvitation    QiitaAPIV2JSONSchemaTeamInvitationObject    `json:"team_invitation"`
	Template          QiitaAPIV2JSONSchemaTemplateObject          `json:"template"`
	User              QiitaAPIV2JSONSchemaUserObject              `json:"user"`
}