json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

Support for variable references

Open dnicolson opened this issue 3 years ago • 10 comments

Unless a property accepts the type string with no applicable validation constraints, variable references will cause validation errors. This can be seen in the aws-ffmpeg-layer example:

PixelSnap 2022-07-28 at 21 08 45@2x

According to the Serverless Variables page, there are at least half a dozen variable formats. The CloudFormation reference is briefly mentioned in this article.

I'm wondering what the best approach would be here, would it be feasible to use a pattern to match {...}/${...} values similar to the Serverless.FilePath sub schema?

dnicolson avatar Jul 28 '22 19:07 dnicolson

@dnicolson we have the Expression in defintion, would that be a better solution?

KillDozerX2 avatar Jul 29 '22 17:07 KillDozerX2

@KillDozerX2 I am not sure what you mean, where is this Expression?

dnicolson avatar Jul 29 '22 18:07 dnicolson

I've also got this problem. I'm enabled event schedules based on stage.

custom:
  scheduleEnabled:
    prod: true
    dev: false

functions:
  move-to-tm:
    handler: dist/move-to-tm.default
    timeout: 30
    events:
      - schedule:
          rate: rate(7 days)
          enabled: ${self:custom.scheduleEnabled.${opt:stage, self:provider.stage}}

image

Sparticuz avatar Oct 20 '22 16:10 Sparticuz

@Sparticuz yeah, we've been facing issues with variable reference.

KillDozerX2 avatar Oct 22 '22 07:10 KillDozerX2

One solution is to work with @pavelvlasov and his vscode intellisense formatter to load the value using language server and then try to validate it agains the schema.

Watch this issue:- https://github.com/threadheap/serverless-ide-vscode/issues/169

KillDozerX2 avatar Jan 31 '23 08:01 KillDozerX2

Is there a workaround? I looked at https://github.com/threadheap/serverless-ide-vscode/issues/169 which mentions a fork. But how do we use it?

andyshinn avatar Feb 08 '23 21:02 andyshinn

Install the extension in vscode?

KillDozerX2 avatar Feb 09 '23 00:02 KillDozerX2

@KillDozerX2 installing the Serverless IDE extension doesn't appear to have any effect. Is there something else that needs to be done?

dnicolson avatar Feb 15 '23 19:02 dnicolson

Hi @KillDozerX2, could you please provide an update on this?

From the first comment, it is unclear what the status of this issue is.

dnicolson avatar Apr 09 '23 23:04 dnicolson

HI @dnicolson Trying to get in touch with author of Serverless IDE still. My expectation is that the schema will be validated only after the variables reference is completed. I don't have much experience with a VSCode extensions, but would be nice to get some help in this area. Or better still to create a new extension for Serverless Framework alone. I will reopen this issue to get feedback from people.

KillDozerX2 avatar Apr 10 '23 05:04 KillDozerX2