Skip to content

openapi: split content.go by construct #1059

Closed

Description

@OmarAlJarrah

Problem

compilers/openapi/internal/operation/content.go (1,142 lines) holds media types, multipart and sequential encoding, headers, examples and request bodies, and the package comment.

Direction

  • encoding.go: part encodings, multipart body parts, sequential (itemEncoding/prefixEncoding) encoding, and the body-model helpers only they use.
  • headers.go: headers and their serialization.
  • examples.go: example lists and spellings.
  • body.go: the request body.
  • content.go keeps media types and content entries. The package comment moves to doc.go.
  • Tests follow their names, including the three TestContent_* tests openapi: split operations.go by construct #1057 left in operations_test.go.
  • internal/resolve/resolve.go cites bodySchemaPointer (content.go); it becomes operation/encoding.go.

Blocked by

#998, #1000 and #1046 edit content.go or its tests; #1057 rewrites operations_test.go.

Done when

  • Every top-level declaration of the package, with its doc comment and any comment between declarations, is byte-identical before and after the move (compared with a throwaway go/ast script), and no golden changes.
  • Comments that name a file name the file the code now lives in, changed in a commit of their own.
  • go test ./compilers/openapi/... passes without -update.

Priority: P4, rule 1 (housekeeping: moves code between files and changes no lowering, validation, IR or emit-contract behaviour). wc -l compilers/openapi/internal/operation/content.go → 1142 (morphic @a1f15b29).

Activity

  1. added
    type:choreRefactor or cleanup, no behavior change
    priority:P4Refactors, tests, CI, hostile-input hardening, cosmetic diagnostics, other formats
    on Oct 21, 2026
  2. OmarAlJarrah commented on Oct 22, 2026

    @OmarAlJarrah
    MemberAuthor

    A fourth TestContent_* test sits outside content_test.go: TestContent_ASharedBodyOrHeaderIsNamedForItsDeclaration, in compilers/openapi/internal/operation/pathitemref_test.go. "Tests follow their names" should take it along with the three in operations_test.go.

    grep -n '^func TestContent_' compilers/openapi/internal/operation/*_test.go | grep -v content_test.go lists all four.

  3. OmarAlJarrah commented on Oct 22, 2026

    @OmarAlJarrah
    MemberAuthor

    If #1099 merges first, the bodySchemaPointer (content.go) citation this issue repoints is in internal/resolve/refsite.go (IsRefSite's comment), not internal/resolve/resolve.go; #1099 splits that file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P4Refactors, tests, CI, hostile-input hardening, cosmetic diagnostics, other formatstype:choreRefactor or cleanup, no behavior change

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions