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

Support OpenAPI reusable responses in global components object (handle $ref properly everywhere) #852

Merged
merged 10 commits into from Apr 16, 2024

Conversation

pmcelhaney
Copy link
Owner

This should fix #838.

  • remove commented out code
  • rename ResponseTypeCoder to ResponsesTypeCoder so we can factor our a coder for an individual response
  • Factored out ResponseTypeCoder so that $refs will be followed
  • code generator now properly handles $ref in a response
  • extract TypeCoder class
  • move the decision on whether to write code directly or import from another script (because the requirement is a $ref) up to Coder / TypeCoder

Copy link

changeset-bot bot commented Apr 13, 2024

⚠️ No Changeset found

Latest commit: 0f9a78c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coveralls
Copy link
Collaborator

coveralls commented Apr 13, 2024

Pull Request Test Coverage Report for Build 8697996524

Details

  • 101 of 103 (98.06%) changed or added relevant lines in 8 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.09%) to 86.607%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/typescript-generator/response-type-coder.js 11 13 84.62%
Files with Coverage Reduction New Missed Lines %
src/typescript-generator/response-type-coder.js 2 95.69%
Totals Coverage Status
Change from base Build 8679856385: 0.09%
Covered Lines: 2879
Relevant Lines: 3369

💛 - Coveralls

// eslint-disable-next-line no-param-reassign
script.comments = READ_ONLY_COMMENTS;

const xType = script.importSharedType("WideOperationArgument");
Copy link
Collaborator

@dethell dethell Apr 15, 2024

Choose a reason for hiding this comment

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

Suggest using an enum instead of hard coded strings:

Suggested change
const xType = script.importSharedType("WideOperationArgument");
const xType = script.importSharedType(SharedType.WideOperationArgument);

Copy link
Owner Author

Choose a reason for hiding this comment

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

These strings appear as both a type name and a runtime value. I don't think there's a way to share across those two different contexts. Otherwise good idea.


const xType = script.importSharedType("WideOperationArgument");

script.importSharedType("OmitValueWhenNever");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above. Likely these types won't ever change, but it seems more future-proof.

remove dead (copy/pasted) code
@pmcelhaney pmcelhaney merged commit 9762407 into main Apr 16, 2024
8 checks passed
@pmcelhaney pmcelhaney deleted the refactor-path-coder branch April 16, 2024 01:14
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.

Support OpenAPI reusable responses in global components object
3 participants