ngrx / platform

Reactive State for Angular
https://ngrx.io
Other
7.96k stars 1.95k forks source link

Schematics 'feature' gives error "Property 'entity' does not match the schema. 'false' should be a 'boolean'." #4278

Closed chriscurnow closed 2 months ago

chriscurnow commented 3 months ago

Which @ngrx/* package(s) are the source of the bug?

schematics

Minimal reproduction of the bug/regression with instructions

I don't know how to issue a terminal command in StackBlitz.

But when I issue the terminal command nx generate @ngrx/schematics:feature [name] I get the error:

Property 'entity' does not match the schema. 'false' should be a 'boolean'.

Expected behavior

When I issue the schematic nx generate @ngrx/schematics:feature [name] it should creat the feature.

I am using Ngrx inside NX but I don't think that makes any difference.

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)

NgRx: 17.1.1

Other information

I think the issue is in line 74 of schema.json of the feature schematic.

It currently reads:

"default": "false"

I think it should be

"default": false

That is, remove the quotation marks around false.

It worked after I made this change.

I would be willing to submit a PR to fix this issue

timdeschryver commented 3 months ago

Hi, I just tried to reproduce this but I was unable to. That being said, the observation you made about false being a string is correct and if you want you can create a PR for this. It could be that this has an impact on the generate command, but I'm not 100% sure that it will fix the issue.

Is the nx generate @ngrx/schematics:feature [name] command interactive for you (does it ask for some information first?). As a workaround you can also try to pass the value to the command nx generate @ngrx/schematics:feature [name] --entity false|true

chriscurnow commented 3 months ago

I'll try and reproduce it from my end in a vanilla Angular (rather than Nx Angular) app. When I tried the change in the schematic schema.json it did fix the issue. It doesn't look like it's urgent but I will create a PR. It did ask me some questions:

Should we generate and wire success and failure actions? (y/N) What should be the prefix of the action, effect and reducer? Should we use @ngrx/entity to create the reducer? (y/N) To which module (path) should the effect be registered in? ·

timdeschryver commented 3 months ago

Thanks in advance @chriscurnow !

timdeschryver commented 2 months ago

Hey @chriscurnow not to rush you, but are you working on this or will you be working on this? Otherwise we'll add it to our v18 backlog.

chriscurnow commented 2 months ago

Thanks for asking.I'm pretty shat out just now so perhaps just add it to the backlog.Sent from my iPadOn 24 Apr 2024, at 4:26 AM, Tim Deschryver @.***> wrote: Hey @chriscurnow not to rush you, but are you working on this or will you be working on this? Otherwise we'll add it to our v18 backlog.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

timdeschryver commented 2 months ago

If someone want to pick this one up, the fix is to update the following line.

https://github.com/ngrx/platform/blob/1a62f87c586d443fa243f603b8b0e87d48b42426/modules/schematics/src/feature/schema.json#L74

false shouldn't be a string value but a boolean value.

geromegrignon commented 2 months ago

PR opened :)

ilirbeqirii commented 2 months ago

PR opened :)

You fast guy 😅