Skip to content

openapi: split auth.go into security requirements, schemes and OAuth flows #1093

Closed

Description

@OmarAlJarrah

Problem

#1062 left internal/auth/auth.go whole because it holds one construct, security. It holds three: LowerSecurityRequirements lowers the requirements an operation or document declares and never reaches the scheme lowering; the scheme lowering fills each scheme's kind and fields; and an OAuth2 scheme's flows, their fields and scopes are a lowering of their own. At ff8330ba the file is 592 lines.

wc -l compilers/openapi/internal/auth/auth.go
grep -nE '^(func|type) ' compilers/openapi/internal/auth/auth.go

Direction

A draft. Each declaration moves with the responsibility it serves.

File Holds
requirements.go LowerSecurityRequirements, lowerSecurityRequirement, writtenAsObject
schemes.go LowerSecuritySchemes, unresolvableSchemeDiags, lowerSecurityScheme, applySchemeAnnotations, mechanismRefusalDiag, tokenless, fillSchemeKind, fillHTTPScheme, mechanismFieldNames, fieldsDefinedBy, preserveUnreadFields
flows.go applyFlowAnnotations, preserveUndefinedFlowFields, flowsMissing, oauthNoFlowDiag, sourceFlow, presentFlows, oauthFlows, oauthFlow, flowField, flowFields, flowFieldsDefinedBy, scopes
doc.go the package comment, which leaves auth.go with it

auth.go is then empty and goes. Tests follow their names where a test names one of the three; the rest stay in auth_test.go and auth_internal_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 and test labels that name a file name the file the code now lives in, changed in a commit of their own: seven cases in compilers/openapi/overlay_test.go are labelled auth.go ….
  • 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/auth/auth.go → 592 (morphic @ff8330ba).

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