Skip to content

docs unclear: faker.unsplash is not defined #412

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

Closed
carlos-nexans opened this issue Feb 3, 2022 · 9 comments · Fixed by #489
Closed

docs unclear: faker.unsplash is not defined #412

carlos-nexans opened this issue Feb 3, 2022 · 9 comments · Fixed by #489
Assignees
Labels
c: bug Something isn't working c: docs Improvements or additions to documentation

Comments

@carlos-nexans
Copy link

carlos-nexans commented Feb 3, 2022

Describe the bug

faker.unsplash is not defined whereas the docs allows to use it (reference)

Reproduction

Minimal code to reproduce:

import faker from '@faker-js/faker'
faker.unsplash.technology()

This code shows a typescript warning

Property 'unsplash' does not exist on type 'Faker'. ts(2339)

When it's run it throws this error

TypeError: Cannot read properties of undefined (reading 'technology')

Additional Info

I found that unsplash is accesible via the image property

import faker from '@faker-js/faker'
faker.image.unsplash.technology()

We should either update the documentation or add unsplash to the Faker top level methods. The first option feels more natural to me. I would like to contribute introducing the fix if needed.

@carlos-nexans carlos-nexans added the s: pending triage Pending Triage label Feb 3, 2022
@ST-DDT
Copy link
Member

ST-DDT commented Feb 3, 2022

It looks like the docs generation does not properly filter elements that arent directly available via faker.

We will fix that. Thanks for bringing this to our attention.

@ST-DDT ST-DDT added c: bug Something isn't working c: docs Improvements or additions to documentation and removed s: pending triage Pending Triage labels Feb 3, 2022
@ST-DDT
Copy link
Member

ST-DDT commented Feb 3, 2022

If you are willing to contribute, then I can assign this issue to you.
The relevant code is in scripts/apidoc.ts.

.getChildrenByKind(TypeDoc.ReflectionKind.Class);

Please note that I'm currently trying to rewrite the code a bit to use vue components so please dont refactor the code unless necessary

@ejcheng ejcheng moved this to Todo in Faker Roadmap Feb 3, 2022
@Shinigami92
Copy link
Member

@cdgn-coding While we are fixing the docs, just use https://stackblitz.com/edit/typescript-wsqtmx?file=index.ts in the meantime

import { faker } from '@faker-js/faker';

faker.image.unsplash.avatar();

@carlos-nexans
Copy link
Author

carlos-nexans commented Feb 3, 2022

I started to use the methods below faker.image.unsplash and it seems to work. Nevertheless, I found that these methods always return the same URL https://source.unsplash.com/category/{category}/640x480, and Unsplash has the responsibility to give randomized images under the category. That doesn't seem to work as intuitively expected.

This example renders images using faker.image.unsplash.technology(), and it's rare to find any that is related to technology. Whereas Unsplash has many more technology-related examples. Do you think we can also improve this behavior?

@ST-DDT
Copy link
Member

ST-DDT commented Feb 3, 2022

I started to use the methods below faker.image.unsplash and it seems to work. Nevertheless, I found that these methods always return the same URL https://source.unsplash.com/category/{category}/640x480, and Unsplash has the responsibility to give randomized images under the category. That doesn't seem to work as intuitively expected.

This example renders images using faker.image.unsplash.technology(), and it's rare to find any that is related to technology. Whereas Unsplash has many more technology-related examples. Do you think we can also improve this behavior?

Yes, but any kind of bugfix of existing code is scheduled for 6.1 or later.
(We first want to have a stable foundation before touching anything.)

@Shinigami92
Copy link
Member

Due to following code works, I will close this issue.

import { faker } from "@faker-js/faker";

faker.image.unsplash.technology();

Please open new dedicated issues for anything that was unrelated to this issue.

Repository owner moved this from Todo to Done in Faker Roadmap Feb 4, 2022
@ST-DDT
Copy link
Member

ST-DDT commented Feb 4, 2022

This is a bug in our documentation, that needs to be fixed.

@ST-DDT ST-DDT reopened this Feb 4, 2022
@ST-DDT ST-DDT moved this from Done to Todo in Faker Roadmap Feb 4, 2022
@Shinigami92 Shinigami92 changed the title faker.unsplash is not defined docs unclear: faker.unsplash is not defined Feb 4, 2022
@ST-DDT ST-DDT assigned ST-DDT and unassigned carlos-nexans Feb 14, 2022
Repository owner moved this from Todo to Done in Faker Roadmap Feb 15, 2022
@ST-DDT ST-DDT removed this from Faker Roadmap Nov 4, 2022
@airtonix
Copy link

Unsplash is deprecating the above urls in two stages:

  • stage one: source.unsplash.com only gives out random images from a extremely limited set of photos
  • stage two: source.unsplash.com will 404

@ST-DDT
Copy link
Member

ST-DDT commented Jan 21, 2023

We deprecated the unsplash apis for removal already.

/**
* @deprecated Use `faker.image` instead.
*/
readonly unsplash: Unsplash;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working c: docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants