Comments (11)
Bad in what sense? It seems to be a valid ECMA-262 regex.
In the original AWS definition it was
{ "pattern":"^[0-9A-Za-z\\.\\-_]*(?<!\\.)$" }
and the output yaml is
pattern: '^[0-9A-Za-z\.\-_]*\(\?<!\.\)$'
So it may have been mangled by convertRegex
.
from aws2openapi.
from aws2openapi.
I'm not sure - as their format is undocumented, but I've assumed it's POSIX BRE.
from aws2openapi.
Use of native JS RegExp here
Seems to indicate it should be a standard ECMA 262 RegExp... but if it was mangled by convertRegex
that means the RegExp constructor throws on it:
SyntaxError: Invalid regular expression: /^[0-9A-Za-z.-_]*(?<!.)$/: Invalid group
Perhaps all we can do is report it upstream?
from aws2openapi.
If the original regexen are ECMA 262 already, why is convertRegex
necessary?
The regex works properly in the aws-sdk, but the regex in their JSON does indeed throw an invalid group when passed to the RegExp constructor...
from aws2openapi.
If the original regexen are ECMA 262 already, why is convertRegex necessary?
Because a number of patterns
in the AWS json files throw errors in the RegExp constructor* and I assumed it was because they were POSIX BREs not ECMA 262 REs. I think the first example I found showed up as BRE syntax in some tool or other.
*and I wanted the resultant OpenAPI definitions to pass validation.
Can you debug the SDK and see if/how it is managing to instantiate the regex?
The lambda client appears to the load the min
version of the API definition, not the normal
one, and the min
version doesn't contain any pattern
properties (or descriptions, or ...).
from aws2openapi.
It looks like the JS client doesn't do any client-side validation actually. Invalid regexen still get sent to the server, which responds with:
{"message":"1 validation error detected: Value 'foo&*' at 'code.s3Bucket' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[0-9A-Za-z\\.\\-_]*(?<!\\.)$"}
from aws2openapi.
According to this cheatsheet, the regex in question is a negative look-behind which says that the string can't end in a .
, so foo-
is legal but not foo.
.
I don't think JS has an equivalent to negative lookbehinds. I think the best solution is to strip the negative lookbehind, which would result in a regex that's more permissive than it should be, but would at least pass for valid strings.
from aws2openapi.
If you're good with that solution I can send a PR
from aws2openapi.
That would be great, thanks.
from aws2openapi.
I think we can close this?
from aws2openapi.
Related Issues (20)
- Duplicate Operation Paging Parameters in S3
- The info.contact.x-twitter field causes openapi-generator to fail HOT 7
- The "members" attribute in the AWS service definition is literally a list of "member" objects HOT 7
- Add tests using moto and pyopenapi HOT 6
- Unexpected "get" requests in generated openapi spec HOT 2
- text/xml in iam spec instead of application/xml, which is what the OpenAPI 3.0 spec supports HOT 3
- The "operationId" field shouldn't have spaces HOT 2
- Converter missing response mappings HOT 1
- x-amz-meta- is wrong for AWS S3 PutObject API HOT 1
- Body in PutObject, UploadPart API's type should by string instead of object HOT 2
- Wrong error response for HeadObject in s3 HOT 3
- S3 API's error not handled correctly HOT 1
- Incorrect usage of additional properties besides $ref for EC2 OpenAPI3 Swagger file HOT 1
- Openapi for endpoints that have pagination end up with duplicate parameters HOT 1
- Incorrect variable type defined in the yaml file
- unexpected multi-type 'allOff' references in runtime.lex.v2 spec
- Query parameters array "serialization" strategy HOT 5
- Support signatureVersion: bearer
- Exception definitions not included
- Duplicate entries in Servers Object
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws2openapi.