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

Generate deprecation annotations based on OpenAPI document #92

Merged
merged 8 commits into from
Jun 27, 2023

Conversation

simonjbeaumont
Copy link
Collaborator

Motivation

The OpenAPI spec supports declaring various parts of the API as deprecated, including operations, parameters, schemas, and properties. These can be surfaced in the generated code by adding @available(*, deprecated) annotations to the functions, types, and properties.

Modifications

  • Support for deprecated OpenAPI schemas.
  • Support for deprecated OpenAPI properties.
  • Support for deprecated OpenAPI operations.

For deprecated operations, these are annotated on the function requirements in the generated APIProtocol.

Result

Deprecated annotations are generated for the parts of the API marked as deprecated in the OpenAPI document.

Test Plan

  • Added #/components/schemas/DeprecatedObject to reference test.
  • Added #/components/schemas/ObjectWithDeprecatedProperty to reference test.
  • Marked #/paths//probe//post operation as deprecated in reference test.
  • Marked #/components/parameters/My-Request-UUID parameter as deprecated in reference test.
  • Unit tests for rendering DeprecatedDescription already existed.

Resolves

Resolves #26.

@simonjbeaumont simonjbeaumont requested a review from czechboy0 June 26, 2023 21:21
@simonjbeaumont simonjbeaumont marked this pull request as draft June 26, 2023 21:26
@simonjbeaumont
Copy link
Collaborator Author

Heh... I hadn't considered that our CI is building with warning-as-error and that this now generates a warning because there's deprecated symbols:

/code/Tests/PetstoreConsumerTests/TestClient.swift:44:29: error: 'probe' is deprecated
        _ input: Operations.probe.Input
                            ^
/code/Tests/PetstoreConsumerTests/TestClient.swift:45:34: error: 'probe' is deprecated
    ) async throws -> Operations.probe.Output {
                                 ^
[215/342] Compiling PetstoreConsumerTests Test_Client.swift
error: fatalError
1
Build step 'Execute shell' marked build as failure

Will update the flags in the CI build.

Copy link
Contributor

@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.

Looks great, thanks! Just added a few nits.

@simonjbeaumont simonjbeaumont requested a review from czechboy0 June 27, 2023 06:32
@simonjbeaumont simonjbeaumont force-pushed the sb-deprecation-support branch from 3f36499 to 7723dc8 Compare June 27, 2023 16:30
@simonjbeaumont simonjbeaumont force-pushed the sb-deprecation-support branch from 7723dc8 to 234770e Compare June 27, 2023 17:06
@simonjbeaumont simonjbeaumont requested a review from czechboy0 June 27, 2023 17:06
@simonjbeaumont simonjbeaumont marked this pull request as ready for review June 27, 2023 17:06
Copy link
Contributor

@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.

Looks great!

@simonjbeaumont simonjbeaumont merged commit 9d9469f into apple:main Jun 27, 2023
simonjbeaumont added a commit that referenced this pull request Jun 29, 2023
### Motivation

In #92 we made some changes to the Compose files for CI. It introduced
some typos in some comments.

### Modifications

Fix typos in the compose files.

### Result

Compose files don't have typos.

### Test Plan

None.

Signed-off-by: Si Beaumont <[email protected]>
@simonjbeaumont simonjbeaumont added the 🆕 semver/minor Adds new public API. label Jul 12, 2023
@czechboy0
Copy link
Contributor

Changing from semver/minor to semver/patch, as it only causes a build error if you explicitly opt in to warnings as errors, in which case we don't consider that a semver break.

@czechboy0 czechboy0 added 🔨 semver/patch No public API change. and removed 🆕 semver/minor Adds new public API. labels Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support deprecated annotations
3 participants