Skip to content

FDN-4939: Add OpenAPI 3.x import support#970

Open
jackl wants to merge 5 commits into
mainfrom
FDN-4416-add-openapi-importer
Open

FDN-4939: Add OpenAPI 3.x import support#970
jackl wants to merge 5 commits into
mainfrom
FDN-4416-add-openapi-importer

Conversation

@jackl
Copy link
Copy Markdown
Contributor

@jackl jackl commented May 20, 2026

Summary

Jira: https://flowio.atlassian.net/browse/FDN-4416

Adds OpenAPI 3.x import support to apibuilder following the same pattern as the existing Swagger 2.0 module.

  • New openapi sbt module with a full schema classification and conversion pipeline (objects, enums, arrays, unions, aliases, maps, security schemes, paths/operations/parameters/responses)
  • Auto-detects OpenAPI 3.x specs (JSON and YAML) in OriginalUtil.guessType, dispatching to OpenApiServiceValidator via OriginalType.UNDEFINED("open_api_3")
  • ConverterMain CLI for developer testing — run directly from sbt while iterating on conversions:
    sbt "openapi/runMain io.apibuilder.openapi.ConverterMain ./openapi.json --organization myorg --json"
    sbt "openapi/runMain io.apibuilder.openapi.ConverterMain https://petstore3.swagger.io/api/v3/openapi.json --organization myorg"
    

Dependencies

  • com.github.apicollective:apibuilder-validation:0.5.8 via JitPack (Scala 3 artifact published without version suffix — uses single %)
  • com.softwaremill.sttp.apispec 0.11.10 for the OpenAPI model

Test plan

  • 67 unit tests covering schema classification, type conversion, security schemes, naming utilities, and end-to-end conversion of three real-world FedEx OpenAPI 3.x specs
  • sbt "openapi/test" → all pass

Notes

  • Uses OriginalType.UNDEFINED("open_api_3") to avoid a blocking API spec change; a follow-up ticket should add a proper OriginalType.OpenApi3 value
  • PathConverter has no dedicated unit spec (covered indirectly via FedEx integration tests); a follow-up can add PathConverterSpec

Eng-Review Summary

  • Revision: a38e28f
  • Timestamp: 2026-05-20T10:46:16Z
  • Status: passed_with_notes
  • Issues:
    • Tag: TESTING
      Title: PathConverter lacks dedicated unit tests
      Location: no PathConverterSpec
      Resolution: justified
      Justification: Covered indirectly via FedEx integration tests in ConverterSpec; unit spec to follow in a subsequent PR

jackl and others added 3 commits May 20, 2026 11:30
Implement OpenAPI 3.x import functionality following the existing Swagger 2.0 pattern. The new openapi module provides:
- Schema classification and conversion pipeline
- Type mapping from OpenAPI schema types to apibuilder scalar types
- Path/operation/parameter conversion
- Security scheme handling
- Full test coverage with FedEx OpenAPI specs

Uses OriginalType.UNDEFINED("open_api_3") for import detection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jackl jackl changed the title FDN-4416: Add OpenAPI 3.x import support FDN-4939: Add OpenAPI 3.x import support May 20, 2026
jackl and others added 2 commits May 20, 2026 15:47
… coverage

- Narrow broad Exception catch in namespace inference to IllegalArgumentException
- Replace unsafe .get calls with sys.error in ConverterMain
- refName warns and returns raw string for non-standard $ref formats
- resolveReference returns Either[String,String] instead of throwing on cycles
- Warn when fields are dropped due to unresolved type (kind=None)
- Warn at each array item type string fallback
- Record issue when path has no typed response and is excluded from resources
- Warn when requestBody $ref cannot be resolved
- Wrap Converter.convert in Try in OpenApiServiceValidator for defence-in-depth
- Wrap fromYaml/fromJson errors with JSON/YAML context prefix
- Include exception class name in fromFile/fromUrl error messages
- Add PathConverterSpec, SchemaResolverSpec, ConverterMainSpec, OpenApiParserSpec
- Expand SchemaConverterSpec with SchemaConverter.convert output assertions
- Expand ConverterSpec: assert resources non-empty, specific model names, filterHeaders e2e
- Add NamingUtils edge cases and ApibuilderPrimitiveTypes membership tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jackl jackl requested a review from mbryzek May 20, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant