swift-openapi-generator icon indicating copy to clipboard operation
swift-openapi-generator copied to clipboard

Consider moving constants from the generator to the runtime

Open czechboy0 opened this issue 2 years ago • 0 comments

Currently we have symbols defined in the runtime package that the generator needs to generate code for.

In order to facilitate this, the generator package contains a Constants file where some of the symbol names are declared as strings.

There are quite a number of such symbols. These are found in Constants.swift.

These could be colocated along with the symbol itself to make it super clear. For example, if we defined an underscored @_spi(Generator) enum SymbolNames {} in runtime and then whenever we are declaring something in runtime that we'll need to generate by name, we can colocate the symbol like this:

+ extension SymbolNames {
+     public static let APIProtocol = "APIProtocol"
+ }
  public protocol APIProtocol { ... }

Some things to consider:

  • this would introduce a build-time dependency from the generator CLI/plugin on the runtime library, which doesn't exist today (the generator package depends on the runtime package for tests, and as a way to communicate which versions work together)
  • the runtime library would expand scope from only being used by the generated code, to also being used by the generator code

czechboy0 avatar May 25 '23 09:05 czechboy0

Deferred.

czechboy0 avatar Aug 09 '23 13:08 czechboy0