Skip to content

Fix Lorem generator API inconsistencies and type mismatches#157

Open
muhammadahmad665 wants to merge 1 commit into
vadymmarkov:masterfrom
muhammadahmad665:fix/lorem-api-alignment-and-type-corrections
Open

Fix Lorem generator API inconsistencies and type mismatches#157
muhammadahmad665 wants to merge 1 commit into
vadymmarkov:masterfrom
muhammadahmad665:fix/lorem-api-alignment-and-type-corrections

Conversation

@muhammadahmad665
Copy link
Copy Markdown

@muhammadahmad665 muhammadahmad665 commented Apr 29, 2026

This PR fixes a few inconsistencies in the Lorem generator so it matches what’s actually documented in Fakery.

A couple of things were slightly off — mainly return types and a few internal implementations that didn’t really line up with the expected API.

What changed

  • words(amount:) now correctly returns [String] instead of a single string
  • Fixed characters(amount:) (it was using a non-existent helper before)
  • Cleaned up sentence formatting so capitalization and punctuation are consistent
  • Simplified a few loops to make things a bit more Swifty and readable

Breaking change

Small one to be aware of:

  • words(amount:) no longer returns a string
  • It now returns an array of words, as per the docs in the readme says

If you were relying on the old behavior, just join it manually:

faker.lorem.words(amount: 3).joined(separator: " ")

- Updated words(amount:) to return [String] instead of String
- Implemented proper random character generation for characters(amount:)
- Fixed sentence capitalization logic
- Refactored loops using map for cleaner Swift style
- Aligned implementation with documented Fakery Lorem API
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