{"id":340893,"date":"2022-11-07T15:00:56","date_gmt":"2022-11-07T15:00:56","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=340893"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=340893","title":{"rendered":"<span>ogen: OpenAPI v3 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f Go<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u0430\u0433\u043e\u0432. \u041f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/github.com\/ogen-go\/ogen\" rel=\"nofollow noopener noreferrer\">ogen<\/a> \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434 \u043f\u043e OpenAPI \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044f \u043e\u0442 \u0441\u043e\u0442\u0435\u043d (\u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0442\u044b\u0441\u044f\u0447) \u0441\u0442\u0440\u043e\u043a \u0441\u043a\u0443\u0447\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 Go, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441 \u0440\u0438\u0441\u043a\u043e\u043c \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0443 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p>  <\/p>\n<p>\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0438\u0448\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440, \u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0418 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 <code>interface{}<\/code> \u0438 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0433\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0435\u043c ogen \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0435\u0433\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"strogaya-tipizaciya\">\u0421\u0442\u0440\u043e\u0433\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>  <\/p>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u0433\u043e-\u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440, \u0447\u0435\u043c-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 gRPC. \u0414\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0438\u0437 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ Handler handles operations described by OpenAPI v3 specification. type Handler interface {     \/\/ AddPet implements addPet operation.     \/\/     \/\/ Creates a new pet in the store. Duplicates are allowed.     \/\/     \/\/ POST \/pets     AddPet(ctx context.Context, req NewPet) (AddPetRes, error)     \/\/ DeletePet implements deletePet operation.     \/\/     \/\/ Deletes a single pet based on the ID supplied.     \/\/     \/\/ DELETE \/pets\/{id}     DeletePet(ctx context.Context, params DeletePetParams) (DeletePetRes, error)     \/\/ FindPetByID implements find pet by id operation.     \/\/     \/\/ Returns a user based on a single ID, if the user does not have access to the pet.     \/\/     \/\/ GET \/pets\/{id}     FindPetByID(ctx context.Context, params FindPetByIDParams) (FindPetByIDRes, error)     \/\/ FindPets implements findPets operation.     \/\/     \/\/ Returns all pets from the system that the user has access to     \/\/     \/\/ GET \/pets     FindPets(ctx context.Context, params FindPetsParams) (FindPetsRes, error)     \/\/ PatchPet implements patchPet operation.     \/\/     \/\/ Patch a pet.     \/\/     \/\/ PATCH \/pets\/{id}     PatchPet(ctx context.Context, req UpdatePet, params PatchPetParams) (PatchPetRes, error) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">func (c *Client) AddPet(ctx context.Context, request NewPet) (res AddPetRes, err error) {}  \/\/ PatchPet invokes patchPet operation. \/\/ \/\/ Patch a pet. \/\/ \/\/ PATCH \/pets\/{id}   func (c *Client) PatchPet(ctx context.Context, request UpdatePet, params PatchPetParams) (res PatchPetRes, err error) {} <\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"validaciya\">\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f<\/h2>\n<p>  <\/p>\n<p>\u0412 ogen \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u044b <code>maxLength<\/code>, <code>minLength<\/code>, <code>pattern<\/code> (regex), <code>minimum<\/code>, <code>maximum<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b \u0441\u0442\u0440\u043e\u043a, \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0447\u0438\u0441\u0435\u043b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">UpdatePet:     type: object     properties:       name:         type: string         maxLength: 25         minLength: 3         pattern: '^[a-zA-Z0-9]+$'       tag:         maxLength: 10         minLength: 1         pattern: '^[a-zA-Z0-9]+$'         nullable: true         type: string<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"neizvestnye-i-obyazatelnye-polya\">\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f<\/h3>\n<p>  <\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u044b, \u0430 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 (\u0435\u0441\u043b\u0438 \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u044b) \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{     0b00000001, } {     if result := (requiredBitSet[i] &amp; mask) ^ mask; result != 0 {         \/\/ Mask only required fields and check equality to mask using XOR.         \/\/         \/\/ If XOR result is not zero, result is not equal to expected, so some fields are missed.         \/\/ Bits of fields which would be set are actually bits of missed fields.         missed := bits.OnesCount8(result)         for bitN := 0; bitN &lt; missed; bitN++ {             bitIdx := bits.TrailingZeros8(result)             fieldIdx := i*8 + bitIdx             var name string             if fieldIdx &lt; len(jsonFieldsNameOfNewPet) {                 name = jsonFieldsNameOfNewPet[fieldIdx]             } else {                 name = strconv.Itoa(fieldIdx)             }             failures = append(failures, validate.FieldError{                 Name:  name,                 Error: validate.ErrFieldRequired,             })             \/\/ Reset bit.             result &amp;^= 1 &lt;&lt; bitIdx         }     } }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"enum\">Enum<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0434\u043b\u044f \u043d\u0438\u0445 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ Ref: #\/components\/schemas\/Kind   type Kind string    const (      KindCat   Kind = \"Cat\"      KindDog   Kind = \"Dog\"      KindFish  Kind = \"Fish\"      KindBird  Kind = \"Bird\"      KindOther Kind = \"Other\"   )  func (s Kind) Validate() error {     switch s {     case \"Cat\":         return nil     case \"Dog\":         return nil     case \"Fish\":         return nil     case \"Bird\":         return nil     case \"Other\":         return nil     default:         return errors.Errorf(\"invalid value: %v\", s)     } }  \/\/ Decode decodes Kind from json. func (s *Kind) Decode(d *jx.Decoder) error {     if s == nil {         return errors.New(\"invalid: unable to decode Kind to nil\")     }     v, err := d.StrBytes()     if err != nil {         return err     }     \/\/ Try to use constant string.     switch Kind(v) {     case KindCat:         *s = KindCat     case KindDog:         *s = KindDog     case KindFish:         *s = KindFish     case KindBird:         *s = KindBird     case KindOther:         *s = KindOther     default:         *s = Kind(v)     }      return nil } <\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u043e\u0442 \u0436\u0435 <code>deepmap\/oapi-codegen<\/code> \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>enum<\/code>-\u043e\u0432, \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044f \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b.<\/p>\n<p>  <\/p>\n<h2 id=\"bez-ukazateley\">\u0411\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439<\/h2>\n<p>  <\/p>\n<p>\u0422\u0430\u043c, \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0434\u043b\u044f \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 (\u0438\u043b\u0438 nullable) \u043f\u043e\u043b\u0435\u0439 \u0432 Go \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">type Pet struct {     \/\/ Name of the pet     Name string `json:\"name\"`      \/\/ Type of the pet     Tag *string `json:\"tag,omitempty\"` }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043f\u0443\u0441\u0442\u044c \u0438 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439, \u043d\u043e \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u0441\u0442\u044b\u043b\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c null pointer exception, \u043f\u0440\u0438\u0432\u0435\u0442 <em>The Billion Dollar Mistake<\/em><\/li>\n<li>\u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043e\u043d\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0430\u0439\u0441 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 <code>[]Pet<\/code>)<\/li>\n<li>\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c nullable optional, \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0442\u0440\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f: \u043f\u0443\u0441\u0442\u043e\u0442\u0430, <code>null<\/code> \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f <code>PATCH<\/code>-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 ogen \u044d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (\u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u0434\u043e\u0448\u043b\u0438):<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ Ref: #\/components\/schemas\/NewPet   type NewPet struct {      Name string    `json:\"name\"`      Tag  OptString `json:\"tag\"`   }  \/\/ OptString is optional string. type OptString struct {      Value string      Set   bool   }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 optional nullable <a href=\"https:\/\/github.com\/deepmap\/oapi-codegen\" rel=\"nofollow noopener noreferrer\">deepmap\/oapi-codegen<\/a> \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ UpdatePet defines model for UpdatePet.   type UpdatePet struct {      Name *string `json:\"name,omitempty\"`      Tag  *string `json:\"tag\"`   }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 ogen \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f <code>OptNilString<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ Ref: #\/components\/schemas\/UpdatePet   type UpdatePet struct {      Name OptString    `json:\"name\"`      Tag  OptNilString `json:\"tag\"`   }  \/\/ OptNilString is optional nullable string. type OptNilString struct {      Value string      Set   bool      Null  bool   }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>OptNilString<\/code> \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0438 <code>null<\/code>, \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>  <\/p>\n<h3 id=\"massivy\">\u041c\u0430\u0441\u0441\u0438\u0432\u044b<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443 <code>nil<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0430\u0439\u0441\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0445\u0435\u043c\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0435 <code>optional<\/code>, \u0442\u043e <code>nil<\/code> \u0431\u0443\u0434\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0430 \u0435\u0441\u043b\u0438 <code>nullable<\/code>, \u0442\u043e <code>null<\/code>. \u0414\u043b\u044f optional nullable \u043f\u043e\u043b\u044f \u0443\u0436\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0443.<\/p>\n<p>  <\/p>\n<h2 id=\"json-bez-refleksii\">JSON \u0411\u0435\u0437 \u0420\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e ogen \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <code>encoding\/json<\/code> \u0441 \u0435\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c, \u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b \u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ Encode encodes string as json. func (o OptNilString) Encode(e *jx.Encoder) {      if !o.Set {         return      }      if o.Null {         e.Null()         return      }      e.Str(string(o.Value))   }  <\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 json \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0438 \u0433\u0438\u0431\u0447\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0435\u043a\u043e\u0434\u0438\u043d\u0433 \u043f\u043e\u043b\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 <code>oneOf<\/code> \u0441 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u043c (\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0430\u0440\u0441\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f-\u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u0443\u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u0438\u043a\u043e\u043c) \u0438 \u0431\u0435\u0437 (\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0438 \u0442\u0438\u043f \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043b\u044f\u043c).<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 json \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/go-faster\/jx\" rel=\"nofollow noopener noreferrer\">go-faster\/jx<\/a>, \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043a <code>jsoniter<\/code>-\u0430 (\u043c\u043e\u0436\u0435\u0442 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442 json \u043b\u043e\u0433\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043d\u0430 \u044f\u0434\u0440\u043e, \u0430 \u043f\u0438\u0441\u0430\u0442\u044c \u2014 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0432\u0443\u0445).<\/p>\n<p>  <\/p>\n<h2 id=\"bez-vneshnego-routera\">\u0411\u0435\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 <code>echo<\/code> \u0438 <code>chi<\/code>, <code>ogen<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0432\u043e\u0439, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u043e\u0443\u0442\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 radix tree:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ ... \/\/ Static code generated router with unwrapped path search. switch { default:     if len(elem) == 0 {         break     }     switch elem[0] {     case '\/': \/\/ Prefix: \"\/pets\"         if l := len(\"\/pets\"); len(elem) >= l &amp;&amp; elem[0:l] == \"\/pets\" {             elem = elem[l:]         } else {             break         }          if len(elem) == 0 {             switch r.Method {             case \"GET\":                 s.handleFindPetsRequest([0]string{}, w, r)             case \"POST\":                 s.handleAddPetRequest([0]string{}, w, r)             default:                 s.notAllowed(w, r, \"GET,POST\")             }              return         }         switch elem[0] {         case '\/': \/\/ Prefix: \"\/\"             if l := len(\"\/\"); len(elem) >= l &amp;&amp; elem[0:l] == \"\/\" {                 elem = elem[l:]             } else {                 break             } \/\/ ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u043e\u0443\u0442\u0435\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439: \u0443\u0431\u0440\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u0434\u043b\u0438\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e <code>runtime.cmpstring<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/go-review.googlesource.com\/c\/go\/+\/357330\" rel=\"nofollow noopener noreferrer\">\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/a> \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0443\u0436\u043d\u043e\u0433\u043e <code>case<\/code> \u0432 <code>switch<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <a href=\"https:\/\/github.com\/go-chi\/chi\/blob\/e5529d9db4d3d45bab5aa1e691e36d45ee5b082f\/tree.go#L799-L808\" rel=\"nofollow noopener noreferrer\">\u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430<\/a>, \u0438 \u0442.\u0434. <\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0451 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u044b\u0448\u0435, \u0447\u0435\u043c \u0443 <code>chi<\/code> \u0438 <code>echo<\/code> (<a href=\"https:\/\/gist.github.com\/tdakkota\/9ef35ce009425a23662108e537b970e2\" rel=\"nofollow noopener noreferrer\">\u043a\u043e\u0434 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0430<\/a>):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">name                        time\/op Router\/GithubStatic\/ogen-4  18.7ns \u00b1 3% Router\/GithubStatic\/chi-4    146ns \u00b1 2% Router\/GithubStatic\/echo-4  73.7ns \u00b1 9% Router\/GithubParam\/ogen-4   34.0ns \u00b1 3% Router\/GithubParam\/chi-4     251ns \u00b1 3% Router\/GithubParam\/echo-4    118ns \u00b1 2% Router\/GithubAll\/ogen-4     56.6\u00b5s \u00b1 3% Router\/GithubAll\/chi-4       323\u00b5s \u00b1 3% Router\/GithubAll\/echo-4      173\u00b5s \u00b1 4%  name                        alloc\/op Router\/GithubStatic\/ogen-4   0.00B Router\/GithubStatic\/chi-4    0.00B Router\/GithubStatic\/echo-4   0.00B Router\/GithubParam\/ogen-4    0.00B Router\/GithubParam\/chi-4     0.00B Router\/GithubParam\/echo-4    0.00B Router\/GithubAll\/ogen-4      0.00B Router\/GithubAll\/chi-4       0.00B Router\/GithubAll\/echo-4      0.00B<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"oneof\">OneOf<\/h2>\n<p>  <\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f-\u0441\u0443\u043c\u043c\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Dog:     type: object     required:       - kind     properties:       kind:         $ref: '#\/components\/schemas\/Kind'       bark:         type: string   Cat:     type: object     required:       - kind     properties:       kind:         $ref: '#\/components\/schemas\/Kind'       meow:         type: string   SomePet:     type: object     discriminator:       propertyName: kind     oneOf:       - $ref: '#\/components\/schemas\/Dog'       - $ref: '#\/components\/schemas\/Cat'<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0451 ogen \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ Ref: #\/components\/schemas\/Cat type Cat struct {     Kind Kind      `json:\"kind\"`     Meow OptString `json:\"meow\"` }  \/\/ Ref: #\/components\/schemas\/Dog type Dog struct {     Kind Kind      `json:\"kind\"`     Bark OptString `json:\"bark\"` }  \/\/ Ref: #\/components\/schemas\/SomePet \/\/ SomePet represents sum type. type SomePet struct {     Type SomePetType \/\/ switch on this field     Dog  Dog     Cat  Cat }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ func (s *SomePet) Decode(d *jx.Decoder) error if err := d.Capture(func(d *jx.Decoder) error {     return d.ObjBytes(func(d *jx.Decoder, key []byte) error {         if found {             return d.Skip()         }         switch string(key) {         case \"kind\":             typ, err := d.Str()             if err != nil {                 return err             }             switch typ {             case \"Cat\":                 s.Type = CatSomePet                 found = true             case \"Dog\":                 s.Type = DogSomePet                 found = true             default:                 return errors.Errorf(\"unknown type %s\", typ)             }             return nil         }         return d.Skip()     }) }); err != nil {     return errors.Wrap(err, \"capture\") } if !found {     return errors.New(\"unable to detect sum type variant\") } switch s.Type { case DogSomePet:     if err := s.Dog.Decode(d); err != nil {         return err     } case CatSomePet:     if err := s.Cat.Decode(d); err != nil {         return err     } default:     return errors.Errorf(\"inferred invalid type: %s\", s.Type) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u043e\u0442 \u0436\u0435 <code>deepmap\/oapi-codegen<\/code> \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0443\u0447\u043d\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 (\u043d\u0443 \u0438 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438, \u0441\u0433\u0435\u043d\u0435\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043c \u043a\u043e\u0434 \u0441\u043b\u043e\u043c\u0430\u043d):<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">\/\/ SomePet defines model for SomePet. type SomePet struct {     union json.RawMessage }  func (t SomePet) Discriminator() (string, error) {     var discriminator struct {         Discriminator string `json:\"kind\"`     }     err := json.Unmarshal(t.union, &amp;discriminator)     return discriminator.Discriminator, err }  \/\/ AsCat returns the union data inside the SomePet as a Cat func (t SomePet) AsCat() (Cat, error) {     var body Cat     err := json.Unmarshal(t.union, &amp;body)     return body, err } <\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0438\u0434\u0438\u043c\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0430\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>Discriminator<\/code>, \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>switch<\/code> \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>AsT() (T, error)<\/code> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h3 id=\"bez-diskriminatora\">\u0411\u0435\u0437 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430<\/h3>\n<p>  <\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, <code>ogen<\/code> \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c <strong>\u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0437 \u043f\u043e\u043b\u044f-\u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430<\/strong>, \u0432\u044b\u0431\u0438\u0440\u0430\u044f \u0442\u0438\u043f \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043b\u044f\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">var found bool if err := d.Capture(func(d *jx.Decoder) error {     return d.ObjBytes(func(d *jx.Decoder, key []byte) error {         switch string(key) {         case \"bark\":             match := DogSomePet             if found &amp;&amp; s.Type != match {                 s.Type = \"\"                 return errors.Errorf(\"multiple oneOf matches: (%v, %v)\", s.Type, match)             }             found = true             s.Type = match         case \"meow\":             match := CatSomePet             if found &amp;&amp; s.Type != match {                 s.Type = \"\"                 return errors.Errorf(\"multiple oneOf matches: (%v, %v)\", s.Type, match)             }             found = true             s.Type = match         }         return d.Skip()     }) }); err != nil {     return errors.Wrap(err, \"capture\") }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 <code>meow<\/code>, \u0442\u043e \u0442\u0438\u043f <code>Cat<\/code>, \u0435\u0441\u043b\u0438 <code>bark<\/code> \u2014 <code>Dog<\/code>, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0448\u043b\u0438, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 <code>unable to detect sum type variant<\/code>.<\/p>\n<p>  <\/p>\n<p>\u042f \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0437\u043d\u0430\u044e \u043a\u0430\u043a\u043e\u0439 \u043b\u0438\u0431\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f OpenAPI, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0441\u043c\u043e\u0433 \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043d\u0430 Go.<\/p>\n<p>  <\/p>\n<h3 id=\"soobscheniya-ob-oshibkah\">\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0438 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">$ go generate   - petstore-expanded.yaml:218:17 -> resolve: can't find value for \"components\/schemas\/Do1\"           217 |       oneOf:             \u2192 218 |         - $ref: '#\/components\/schemas\/Do1'                     |                 \u2191                  219 |         - $ref: '#\/components\/schemas\/Cat'                 220 |                    221 |     UpdatePet: <\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"v-itoge\">\u0412 \u0438\u0442\u043e\u0433\u0435<\/h2>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 <code>ogen<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0432\u0438\u0436\u0443:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0421\u0442\u0440\u043e\u0433\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/li>\n<li>\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f<\/li>\n<li>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 <code>oneOf<\/code> \u0438 <code>anyOf<\/code>, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0431\u0435\u0437 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u0432<\/li>\n<li>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c <code>nullable optional<\/code><\/li>\n<li>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u043e\u0443\u0442\u0435\u0440<\/li>\n<li>\u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 json<\/li>\n<li>\u0423\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u0432 \u0441\u0445\u0435\u043c\u0435<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/694090\/\"> https:\/\/habr.com\/ru\/post\/694090\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u0430\u0433\u043e\u0432. \u041f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/github.com\/ogen-go\/ogen\" rel=\"nofollow noopener noreferrer\">ogen<\/a> \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434 \u043f\u043e OpenAPI \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044f \u043e\u0442 \u0441\u043e\u0442\u0435\u043d (\u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0442\u044b\u0441\u044f\u0447) \u0441\u0442\u0440\u043e\u043a \u0441\u043a\u0443\u0447\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 Go, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441 \u0440\u0438\u0441\u043a\u043e\u043c \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0443 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p>  <\/p>\n<p>\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0438\u0448\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440, \u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0418 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 <code>interface{}<\/code> \u0438 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0433\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0435\u043c ogen \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0435\u0433\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-340893","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=340893"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340893\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}