You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CORS config TS types (both here and in @types) don't match the schema #49
The current type in @types/serverless is incomplete (missing origin and methods properties) and inaccurate (one of origin or origins is required, not optional, making it easy to run into serverless/serverless#9858). Also, all the optional properties have | undefined appended which AFAIK is redundant and unnecessary.
Thanks for pointing out this issue @justingrant .
Types from this repository are auto-generated from schema located in https://github.com/serverless/serverless. The library handling the type generation is struggling with the oneOf keyword located in the required section of the CORS schema. Once it is removed, chances are next type generation will be much more accurate.
I tried removing this oneOf property to give it a try and actually got correctly generated types
changed the title [-]CORS config TS types (both here and in @types) don't mach the schema[/-][+]CORS config TS types (both here and in @types) don't match the schema[/+]on Sep 1, 2021
I've also just come across this. In my case, I'm interested in the exposedResponseHeaders property that is available in the YAML configuration but not in the TypeScript equivalent:
The documentation you're referring to is for httpApi event types, that are provisioned with API Gateway HTTP API.
However the code base containing CORS schema you're referring to is for http event types, that are provisioned with API Gateway Rest API. Those are not the same and does not share the same capabilities.
Thanks @fredericbarthelet - that's really helpful! I didn't realise I had the two things mixed up. It turns out that I was still using the old community-maintained Definitely Typed package rather than your new one: so now I've upgraded and everything is working as expected.
Activity
fredericbarthelet commentedon Aug 20, 2021
Thanks for pointing out this issue @justingrant .
Types from this repository are auto-generated from schema located in https://github.com/serverless/serverless. The library handling the type generation is struggling with the
oneOfkeyword located in the required section of the CORS schema. Once it is removed, chances are next type generation will be much more accurate.I tried removing this

oneOfproperty to give it a try and actually got correctly generated typesjustingrant commentedon Aug 20, 2021
Those types don't actually look correct:
originororiginsis required or validation will fail (AWS API Gateway: Improve validation of CORS configuration serverless#9858)headers(and maybemethodstoo?) accepts a comma-delimitedstringas well as astring[]integration?: string | string | string | string ...is that missing the string enum values?[-]CORS config TS types (both here and in @types) don't mach the schema[/-][+]CORS config TS types (both here and in @types) don't match the schema[/+]ed-graham commentedon Oct 18, 2021
I've also just come across this. In my case, I'm interested in the
exposedResponseHeadersproperty that is available in the YAML configuration but not in the TypeScript equivalent:(from https://www.serverless.com/blog/aws-http-api-support#configuring-cors).
I notice that
exposedResponseHeadersis not listed as a valid property in the CORS schema. Is there a reason for that?fredericbarthelet commentedon Oct 18, 2021
Hi @ed-graham, the
exposedResponseHeadersproperty is available in the typescript definition from this repository intypescript/index.d.ts
Line 821 in bc84be8
The documentation you're referring to is for
httpApievent types, that are provisioned with API Gateway HTTP API.However the code base containing CORS schema you're referring to is for
httpevent types, that are provisioned with API Gateway Rest API. Those are not the same and does not share the same capabilities.ed-graham commentedon Oct 19, 2021
Thanks @fredericbarthelet - that's really helpful! I didn't realise I had the two things mixed up. It turns out that I was still using the old community-maintained Definitely Typed package rather than your new one: so now I've upgraded and everything is working as expected.