Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: Flesh out Makefile-based example #489

Merged

Conversation

simonjbeaumont
Copy link
Collaborator

Motivation

We have an example project showing ahead-of-time generation using the swift-openapi-generator CLI directly, driven by a Makefile. This PR polishes it up a bit and makes it more flexible. Additionally, the generated code had not been updated since we switched the default access modifier from package to internal.

Modifications

  • Allow overriding a bunch of things when calling make.
  • Prompt for confirmation before blowing away the output directory.
  • Regenerate sources to pick up the new access modifier.
  • Add a help target.

Result

More extensive example.

E.g. running the following command:

% make help
Run make with one of the following targets:

  help:          Display this help.
  generate:      Generate the sources using swift-openapi-generator.
  build:         Runs swift build.
  clean:         Delete the output directory used for generated sources.
  clean-all:     Clean everything, including the checkout of swift-openapi-generator.
  dump:          Dump all derived values used by the Makefile.

The following options can be overriden on the command line:

  SWIFT_OPENAPI_GENERATOR_GIT_URL (e.g. https://github.com/apple/swift-openapi-generator)
  SWIFT_OPENAPI_GENERATOR_GIT_TAG (e.g. 1.0.0)
  SWIFT_OPENAPI_GENERATOR_CLONE_DIR (e.g. .swift-openapi-generator)
  SWIFT_OPENAPI_GENERATOR_BUILD_CONFIGURATION (e.g. release)
  OPENAPI_YAML_PATH (e.g. openapi.yaml)
  OPENAPI_GENERATOR_CONFIG_PATH (e.g. openapi-generator-config.yaml)
  OUTPUT_DIRECTORY (e.g. Sources/ManualGeneratorInvocationClient/Generated)

Test Plan

CI should still build the package.

Copy link
Collaborator

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one suggestion

@simonjbeaumont simonjbeaumont merged commit 9ba2457 into apple:main Dec 14, 2023
9 checks passed
@czechboy0 czechboy0 added the semver/none No version bump required. label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants