profile
viewpoint

ErikWittern/TODOit 101

The JavaScript framework for hassle-free TODO application development.

ErikWittern/openapi-snippet 27

Generates code snippets for given Swagger / Open API documents

amaurremi/stringoid 5

Retrieving URLs from APK files

ErikWittern/gravityquest_demo 5

Demo of the game Gravity Quest developed with Phaser

ErikWittern/graphql-schema-collector 3

Scripts to mine GitHub for GraphQL schemas, defined in the Schema Definition Language.

ErikWittern/graphql-schemas 3

GraphQL schema definitions mined from GitHub

ErikWittern/timer.js 3

Timer.js is a small JavaScript library to set up and handle timed events.

Alan-Cha/Immutable-no-more 2

A repository that moves around - or not.

push eventwittern/wittern.github.io

ErikWittern

commit sha e0b82cb7ad73edde4301a0e3d6dece103e715338

Minor CV fixes

view details

push time in 20 hours

push eventwittern/wittern.github.io

ErikWittern

commit sha b013af275caf4af82bc987aaeceed7f59b770e71

CV fixes

view details

push time in 20 hours

push eventwittern/wittern.github.io

ErikWittern

commit sha 5da14786b347cc2442c4d71a5965f62579118a03

Style

view details

push time in 20 hours

push eventwittern/wittern.github.io

ErikWittern

commit sha 188eeb64f9d6210005a208ed2d34c95e14d00dfc

Fix CV links

view details

push time in 2 days

push eventwittern/wittern.github.io

ErikWittern

commit sha eb3ff9d7ca97cfc78902f2195ad40badadec7614

Minor fix

view details

push time in 2 days

push eventwittern/wittern.github.io

ErikWittern

commit sha 8ac2e55108af09bfa78783ab3f8f10a9c412cadb

New CV

view details

push time in 2 days

push eventwittern/wittern.github.io

ErikWittern

commit sha 0ce8d97178567622601c53cb6f049753b5badf36

Update Jekyll version

view details

push time in 2 days

issue commentErikWittern/openapi-snippet

Issue when Security Scheme is of type oauth2

@niteshhegde Thank you!

niteshhegde

comment created time in 16 days

pull request commentIBM/openapi-to-graphql

Suport arbitrary JSON pointer references

@mtth Thank you for the PR, it is important that we get these things right.

I think that the specific issue you point out could also have been fixed by an additional call to unescape at the beginning of resolveRef. For example, unescape('#/paths/~1users~1%7bid%7d/description') (from your test case) yields '#/paths/~1users~1{id}/description'. As such, there is a tradeoff here between a small fix for the specific issue vs. introducing a new runtime dependency. I do like that json-ptr has itself no dependencies, though, and is relatively small with ~90kb (as long as we are not talking browser). And I guess it will resolve other (edge-) cases that our resolveRef (obviously) currently misses. So LGTM!

mtth

comment created time in 16 days

created tagErikWittern/openapi-snippet

tagv0.9.0

Generates code snippets for given Swagger / Open API specification files.

created time in 17 days

release ErikWittern/openapi-snippet

v0.9.0

released time in 17 days

pull request commentErikWittern/openapi-snippet

OpenAPI 3.0 securitySchemes fix for oauth2

@niteshhegde Thanks for the PR!

@RolphH Very sorry for the late reply, and thanks for reminding me again. I merged also your other PR https://github.com/ErikWittern/openapi-snippet/pull/45 and published a new version 0.9.0

niteshhegde

comment created time in 17 days

push eventErikWittern/openapi-snippet

ErikWittern

commit sha 70d96d4d1418d0c09ee9ea181e501155392757fc

Update version

view details

push time in 17 days

push eventErikWittern/openapi-snippet

Rolph Haspers

commit sha db6288f82061c7dd06f175d95e5e4a5d6733fd25

Replace path parameters with example values

view details

Erik Wittern

commit sha 73d996c8f4ff405797a91c368739ba561d9fca13

Merge pull request #45 from RolphH/feature/add-example-uri-values Replace path parameters with example values

view details

push time in 17 days

PR merged ErikWittern/openapi-snippet

Replace path parameters with example values

Added small feature to have the Uri parameters replaced with the example values when specified. This will create better code-snippets which can be used easily, instead of having {parameter} in your code-snippet.

+28 -1

0 comment

1 changed file

RolphH

pr closed time in 17 days

push eventErikWittern/openapi-snippet

Nitesh Hegde

commit sha bcd94d2e524f466bb851e0b43833c08379697112

OpenAPI 3.0 securityschemes fix for oauth2

view details

Nitesh Hegde

commit sha 20b24414a51f00977bba4928b53bbb5075600955

Merge pull request #1 from niteshhegde/oauth2_securityscheme_fix_oas3 OpenAPI 3.0 securityschemes fix for oauth2

view details

Erik Wittern

commit sha 8784611f259f310f1d7a2dc141e45da3717c81e6

Merge pull request #42 from niteshhegde/master OpenAPI 3.0 securitySchemes fix for oauth2

view details

push time in 17 days

PR merged ErikWittern/openapi-snippet

OpenAPI 3.0 securitySchemes fix for oauth2

Fix for securitySchemes validations in OpenAPI 3.0 for type "oauth2" Ref: https://swagger.io/docs/specification/authentication/oauth2/

For OAS: "securitySchemes": { "oauth2": { "type": "oauth2", "flows": { } } } This causes the code to fail at: "authScheme = secDefinition.scheme.toLowerCase();" as scheme doesn't exist for type oauth2. Thereby, causing 'Cannot call method 'toLowerCase' of undefined'.

+1 -1

2 comments

1 changed file

niteshhegde

pr closed time in 17 days

pull request commentIBM/openapi-to-graphql

added stricter scalar type checks

@isocroft Thanks for the update. I left a few comments in the code, mostly about formatting / comments.

Besides that, as @Alan-Cha also suggested, this PR should include tests. Not only to make sure it does what it intends to do, but also as another means of documenting the new functionality. Would you be willing to add them?

isocroft

comment created time in 2 months

Pull request review commentIBM/openapi-to-graphql

added stricter scalar type checks

 export const mitigations = {   OAUTH_SECURITY_SCHEME: `Ignore security scheme` } +const MAX_INT = 2147483647+const MIN_INT = -2147483648++const MAX_LONG = 9007199254740991+const MIN_LONG = -9007199254740992++/**+ * verify that a variable contains a safe int (2^31)+ */+export function isSafeInteger(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    n <= MAX_INT &&+    n >= MIN_INT &&+    n % 1 === 0+  )+}++/**+ * verify that a variable contains a safe long (2^53)+ */++export function isSafeLong(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    n <= MAX_LONG &&+    n >= MIN_LONG &&+    n % 1 === 0+  )+}++/**+ *+ */++export function isSafeFloat(n: unknown): boolean {+  return typeof n === 'number' && n % 0.5 !== 0+}++/**+ * convert a date and/or date-time string into a date object+ */++function toDate(n: string) {+  const parsed = Date.parse(n)+  const $ref = new Date()++  $ref.setTime(parsed)++  return (+    (typeof parsed === 'number' &&+      parsed !== NaN &&+      parsed > 0 &&+      String(parsed).length === 13 &&+      $ref) ||+    null+  )+}++/**+ * serialize a date string into the ISO format+ */++export function serializeDate(n: string) {+  const date = toDate(n)+  return date && date.toJSON()+}++/**+ * verify that a vriable contains a safe date/date-time string+ */++export function isSafeDate(n: string): boolean {+  const date = toDate(n)+  return date !== null && date.getTime() !== NaN+}++/**+ * verify is a string is a valid URL+ */++export function isURL(s: string): boolean {+  let res = null+  const urlRegex = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z0-9]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g+  try {+    res = s.match(urlRegex)+  } catch (e) {+    res = null+  }+  return res !== null+}++/**+ * verify if a string is a valid EMAIL+ * See: https://github.com/Urigo/graphql-scalars/blob/master/src/resolvers/EmailAddress.ts#L4+ */++export function isEmail(s: string): boolean {+  const emailRegex = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/+  return emailRegex.test(s)+}++/**+ * verify if a string is a valid GUID/UUID+ * See: https://github.com/Urigo/graphql-scalars/blob/master/src/resolvers/GUID.ts#L4+ */++export function isUUIDOrGUID(s: string): boolean {+  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i+  const guidRegExp = /^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/gi++  if (s.startsWith('{')) {+    s = s.substring(1, s.length - 1)+  }++  return uuidRegExp.test(s) || guidRegExp.test(s)+}++/**+ * convert the fist letter of a word in a string to upper case+ */++export function ucFirst(s: string): string {+  if (typeof s !== 'string') {+    return ''+  }++  return s.replace(/^./, c => c.toUpperCase())+}++/**+ * check if a literal is falsy or not+ */+const isLiteralFalsey = (variable: unknown): boolean => {+  return variable === '' || variable === false || variable === 0+}++/**+ * check if a variable contains a reference type (not a literal)+ */++const isPrimitive = (arg: any): boolean => {+  return (+    typeof arg === 'object' || (Boolean(arg) && typeof arg.apply === 'function')+  )+}++/**+ * provide the name of primitive and/or reference types+ */+const checkTypeName = (target: unknown, type: string): boolean => {

@isocroft Not sure the above comment describes what this function does accurately. It seems again to check that the given target (why not use "value" here?) is of the given type. Is that correct? The comment makes it seem as if a name of a primitive and/or type is returned.

isocroft

comment created time in 2 months

Pull request review commentIBM/openapi-to-graphql

added stricter scalar type checks

 export const mitigations = {   OAUTH_SECURITY_SCHEME: `Ignore security scheme` } +const MAX_INT = 2147483647+const MIN_INT = -2147483648++const MAX_LONG = 9007199254740991+const MIN_LONG = -9007199254740992++/**+ * verify that a variable contains a safe int (2^31)+ */+export function isSafeInteger(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    n <= MAX_INT &&+    n >= MIN_INT &&+    n % 1 === 0+  )+}++/**+ * verify that a variable contains a safe long (2^53)+ */++export function isSafeLong(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    n <= MAX_LONG &&+    n >= MIN_LONG &&+    n % 1 === 0+  )+}++/**+ *+ */++export function isSafeFloat(n: unknown): boolean {+  return typeof n === 'number' && n % 0.5 !== 0+}++/**+ * convert a date and/or date-time string into a date object+ */++function toDate(n: string) {+  const parsed = Date.parse(n)+  const $ref = new Date()++  $ref.setTime(parsed)++  return (+    (typeof parsed === 'number' &&+      parsed !== NaN &&+      parsed > 0 &&+      String(parsed).length === 13 &&+      $ref) ||+    null+  )+}++/**+ * serialize a date string into the ISO format+ */++export function serializeDate(n: string) {+  const date = toDate(n)+  return date && date.toJSON()+}++/**+ * verify that a vriable contains a safe date/date-time string+ */++export function isSafeDate(n: string): boolean {+  const date = toDate(n)+  return date !== null && date.getTime() !== NaN+}++/**+ * verify is a string is a valid URL+ */++export function isURL(s: string): boolean {+  let res = null+  const urlRegex = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z0-9]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g+  try {+    res = s.match(urlRegex)+  } catch (e) {+    res = null+  }+  return res !== null+}++/**+ * verify if a string is a valid EMAIL+ * See: https://github.com/Urigo/graphql-scalars/blob/master/src/resolvers/EmailAddress.ts#L4+ */++export function isEmail(s: string): boolean {+  const emailRegex = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/+  return emailRegex.test(s)+}++/**+ * verify if a string is a valid GUID/UUID+ * See: https://github.com/Urigo/graphql-scalars/blob/master/src/resolvers/GUID.ts#L4+ */++export function isUUIDOrGUID(s: string): boolean {+  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i+  const guidRegExp = /^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/gi++  if (s.startsWith('{')) {+    s = s.substring(1, s.length - 1)+  }++  return uuidRegExp.test(s) || guidRegExp.test(s)+}++/**+ * convert the fist letter of a word in a string to upper case+ */++export function ucFirst(s: string): string {+  if (typeof s !== 'string') {+    return ''+  }++  return s.replace(/^./, c => c.toUpperCase())+}++/**+ * check if a literal is falsy or not+ */+const isLiteralFalsey = (variable: unknown): boolean => {+  return variable === '' || variable === false || variable === 0+}++/**+ * check if a variable contains a reference type (not a literal)+ */+

@isocroft Minor: Please remove the empty line between the comment and the function it describes to be in line with the rest of the code base.

isocroft

comment created time in 2 months

Pull request review commentIBM/openapi-to-graphql

added stricter scalar type checks

 export const mitigations = {   OAUTH_SECURITY_SCHEME: `Ignore security scheme` } +const MAX_INT = 2147483647+const MIN_INT = -2147483648++const MAX_LONG = 9007199254740991+const MIN_LONG = -9007199254740992++/**+ * verify that a variable contains a safe int (2^31)+ */+export function isSafeInteger(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    n <= MAX_INT &&+    n >= MIN_INT &&+    n % 1 === 0+  )+}++/**+ * verify that a variable contains a safe long (2^53)+ */++export function isSafeLong(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    n <= MAX_LONG &&+    n >= MIN_LONG &&+    n % 1 === 0+  )+}++/**+ *+ */++export function isSafeFloat(n: unknown): boolean {+  return typeof n === 'number' && n % 0.5 !== 0+}++/**+ * convert a date and/or date-time string into a date object+ */++function toDate(n: string) {+  const parsed = Date.parse(n)+  const $ref = new Date()++  $ref.setTime(parsed)++  return (+    (typeof parsed === 'number' &&+      parsed !== NaN &&+      parsed > 0 &&+      String(parsed).length === 13 &&+      $ref) ||+    null+  )+}++/**+ * serialize a date string into the ISO format+ */++export function serializeDate(n: string) {+  const date = toDate(n)+  return date && date.toJSON()+}++/**+ * verify that a vriable contains a safe date/date-time string+ */++export function isSafeDate(n: string): boolean {+  const date = toDate(n)+  return date !== null && date.getTime() !== NaN+}++/**+ * verify is a string is a valid URL+ */++export function isURL(s: string): boolean {+  let res = null+  const urlRegex = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z0-9]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g+  try {+    res = s.match(urlRegex)+  } catch (e) {+    res = null+  }+  return res !== null+}++/**+ * verify if a string is a valid EMAIL+ * See: https://github.com/Urigo/graphql-scalars/blob/master/src/resolvers/EmailAddress.ts#L4+ */++export function isEmail(s: string): boolean {+  const emailRegex = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/+  return emailRegex.test(s)+}++/**+ * verify if a string is a valid GUID/UUID+ * See: https://github.com/Urigo/graphql-scalars/blob/master/src/resolvers/GUID.ts#L4+ */++export function isUUIDOrGUID(s: string): boolean {+  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i+  const guidRegExp = /^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/gi++  if (s.startsWith('{')) {+    s = s.substring(1, s.length - 1)+  }++  return uuidRegExp.test(s) || guidRegExp.test(s)+}++/**+ * convert the fist letter of a word in a string to upper case+ */++export function ucFirst(s: string): string {+  if (typeof s !== 'string') {+    return ''+  }++  return s.replace(/^./, c => c.toUpperCase())+}++/**+ * check if a literal is falsy or not+ */+const isLiteralFalsey = (variable: unknown): boolean => {+  return variable === '' || variable === false || variable === 0+}++/**+ * check if a variable contains a reference type (not a literal)+ */++const isPrimitive = (arg: any): boolean => {+  return (+    typeof arg === 'object' || (Boolean(arg) && typeof arg.apply === 'function')+  )+}++/**+ * provide the name of primitive and/or reference types+ */+const checkTypeName = (target: unknown, type: string): boolean => {+  let typeName = ''++  // we need to separate checks for literal types and+  // primitive types so we can speed up performance and+  // keep things simple+  if (isLiteralFalsey(target) || !isPrimitive(target)) {+    // literal+    typeName = typeof target+  } else {+    // primitive/reference+    typeName = Object.prototype.toString+      .call(target)+      .replace(/^\[object (.+)\]$/, '$1')+  }++  // check if the type matches+  return Boolean(typeName.toLowerCase().indexOf(type) + 1)+}++/**+ * get the correct type of a variable

@isocroft Minor: Can you capitalize the first word of comments to be in line with the rest of the codebase?

isocroft

comment created time in 2 months

Pull request review commentIBM/openapi-to-graphql

added stricter scalar type checks

 export const mitigations = {   OAUTH_SECURITY_SCHEME: `Ignore security scheme` } +const MAX_INT = 2147483647+const MIN_INT = -2147483648++const MAX_LONG = 9007199254740991+const MIN_LONG = -9007199254740992++/**+ * verify that a variable contains a safe int (2^31)+ */+export function isSafeInteger(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    n <= MAX_INT &&+    n >= MIN_INT &&+    n % 1 === 0+  )+}++/**+ * verify that a variable contains a safe long (2^53)+ */++export function isSafeLong(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    n <= MAX_LONG &&+    n >= MIN_LONG &&+    n % 1 === 0+  )+}++/**+ *+ */++export function isSafeFloat(n: unknown): boolean {+  return typeof n === 'number' && n % 0.5 !== 0+}++/**+ * convert a date and/or date-time string into a date object+ */++function toDate(n: string) {+  const parsed = Date.parse(n)+  const $ref = new Date()++  $ref.setTime(parsed)++  return (+    (typeof parsed === 'number' &&+      parsed !== NaN &&+      parsed > 0 &&+      String(parsed).length === 13 &&+      $ref) ||+    null+  )+}++/**+ * serialize a date string into the ISO format+ */++export function serializeDate(n: string) {+  const date = toDate(n)+  return date && date.toJSON()+}++/**+ * verify that a vriable contains a safe date/date-time string+ */++export function isSafeDate(n: string): boolean {+  const date = toDate(n)+  return date !== null && date.getTime() !== NaN+}++/**+ * verify is a string is a valid URL+ */++export function isURL(s: string): boolean {+  let res = null+  const urlRegex = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z0-9]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g+  try {+    res = s.match(urlRegex)+  } catch (e) {+    res = null+  }+  return res !== null+}++/**+ * verify if a string is a valid EMAIL+ * See: https://github.com/Urigo/graphql-scalars/blob/master/src/resolvers/EmailAddress.ts#L4+ */++export function isEmail(s: string): boolean {+  const emailRegex = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/+  return emailRegex.test(s)+}++/**+ * verify if a string is a valid GUID/UUID+ * See: https://github.com/Urigo/graphql-scalars/blob/master/src/resolvers/GUID.ts#L4+ */++export function isUUIDOrGUID(s: string): boolean {+  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i+  const guidRegExp = /^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/gi++  if (s.startsWith('{')) {+    s = s.substring(1, s.length - 1)+  }++  return uuidRegExp.test(s) || guidRegExp.test(s)+}++/**+ * convert the fist letter of a word in a string to upper case+ */++export function ucFirst(s: string): string {+  if (typeof s !== 'string') {+    return ''+  }++  return s.replace(/^./, c => c.toUpperCase())+}++/**+ * check if a literal is falsy or not+ */+const isLiteralFalsey = (variable: unknown): boolean => {+  return variable === '' || variable === false || variable === 0+}++/**+ * check if a variable contains a reference type (not a literal)+ */++const isPrimitive = (arg: any): boolean => {+  return (+    typeof arg === 'object' || (Boolean(arg) && typeof arg.apply === 'function')+  )+}++/**+ * provide the name of primitive and/or reference types+ */+const checkTypeName = (target: unknown, type: string): boolean => {+  let typeName = ''++  // we need to separate checks for literal types and+  // primitive types so we can speed up performance and+  // keep things simple+  if (isLiteralFalsey(target) || !isPrimitive(target)) {+    // literal+    typeName = typeof target+  } else {+    // primitive/reference+    typeName = Object.prototype.toString+      .call(target)+      .replace(/^\[object (.+)\]$/, '$1')+  }++  // check if the type matches+  return Boolean(typeName.toLowerCase().indexOf(type) + 1)+}++/**+ * get the correct type of a variable+ */+export function strictTypeOf(value: unknown, type: string): boolean {

@isocroft Maybe rename to isStrictTypeOf to indicate that the return value is boolean.

Also, I don't think the comment on top the function accurately explains what the function does. It seems to check whether the given value adheres to the type, which stems from a JSON schema from the OpenAPI, correct? Whereas the comment makes it seems as if the type (or at least the name of the type) of the given value is returned.

isocroft

comment created time in 2 months

Pull request review commentIBM/openapi-to-graphql

added stricter scalar type checks

 export const mitigations = {   OAUTH_SECURITY_SCHEME: `Ignore security scheme` } +const MAX_INT = 2147483647+const MIN_INT = -2147483648++const MAX_LONG = 9007199254740991+const MIN_LONG = -9007199254740992++/**+ * verify that a variable contains a safe int (2^31)+ */+export function isSafeInteger(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    Math.floor(n) === n &&+    n <= MAX_INT &&+    n >= MIN_INT+  )+}++/**+ * verify that a variable contains a safe long (2^53)+ */++export function isSafeLong(n: unknown): boolean {+  return typeof n === 'number' && isFinite(n) && n <= MAX_LONG && n >= MIN_LONG+}++/**+ *+ */++export function isSafeFloat(n: unknown): boolean {+  return typeof n === 'number' && n % 1 !== 0+}++/**+ *+ */++function toDate(n: string) {+  const parsed = Date.parse(n)+  const $ref = new Date()++  $ref.setTime(parsed)++  return (+    (typeof parsed === 'number' &&+      parsed !== NaN &&+      parsed > 0 &&+      String(parsed).length === 13 &&+      $ref) ||+    null+  )+}++/**+ *+ */++export function serializeDate(n: string) {+  const date = toDate(n)+  return date && date.toJSON()+}++/**+ * verify that a vriable contains a safe date/date-time string+ */++export function isSafeDate(n: string): boolean {+  const date = toDate(n)+  return date !== null && date.getTime() !== NaN+}++/**+ *+ */++export function isURL(s: string): boolean {+  let res = null+  const urlRegex = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z0-9]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g+  try {+    res = s.match(urlRegex)+  } catch (e) {+    res = null+  }+  return res !== null+}++/**+ *+ */++export function isEmail(s: string): boolean {+  const emailRegex = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/+  return emailRegex.test(s)+}++/**+ *+ */++export function isUUIDOrGUID(s: string): boolean {+  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i+  const guidRegExp = /^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/gi++  if (s.startsWith('{')) {+    s = s.substring(1, s.length - 1)+  }++  return uuidRegExp.test(s) || guidRegExp.test(s)+}++/**+ *+ */++export function ucFirst(s: string): string {+  if (typeof s !== 'string') {+    return ''+  }++  return s.replace(/^./, c => c.toUpperCase())+}++/**+ * check if a literal is falsy or not+ */+const isLiteralFalsey = (variable): boolean => {+  return variable === '' || variable === false || variable === 0+}++/**+ * provide the name of primitive and/or reference types+ */+const checkTypeName = (target, type): boolean => {+  let typeName = ''++  if (isLiteralFalsey(target)) {+    typeName = typeof target+  } else {+    typeName = '' + (target && target.constructor.name)+  }+  return !!(typeName.toLowerCase().indexOf(type) + 1)+}++/**+ * get the correct type of a variable+ */+export function strictTypeOf(value, type): boolean {+  let result = false

@isocroft I think it would be helpful to improve the documentation of this function. Both arguments are typed as any, but isn't at least the second supposed to be a string? The comment for the function states get the correct type of a variable. Could you elaborate on the context? It seems we are comparing a runtime value with what is defined in a JSON schema definition here, is that correct? I think it would also help to add some inline comments within this function - at least I am having issues following what it does.

isocroft

comment created time in 2 months

Pull request review commentIBM/openapi-to-graphql

added stricter scalar type checks

 export const mitigations = {   OAUTH_SECURITY_SCHEME: `Ignore security scheme` } +const MAX_INT = 2147483647+const MIN_INT = -2147483648++const MAX_LONG = 9007199254740991+const MIN_LONG = -9007199254740992++/**+ * verify that a variable contains a safe int (2^31)+ */+export function isSafeInteger(n: unknown): boolean {+  return (+    typeof n === 'number' &&+    isFinite(n) &&+    Math.floor(n) === n &&+    n <= MAX_INT &&+    n >= MIN_INT+  )+}++/**+ * verify that a variable contains a safe long (2^53)+ */++export function isSafeLong(n: unknown): boolean {+  return typeof n === 'number' && isFinite(n) && n <= MAX_LONG && n >= MIN_LONG+}++/**+ *+ */++export function isSafeFloat(n: unknown): boolean {+  return typeof n === 'number' && n % 1 !== 0+}++/**+ *+ */++function toDate(n: string) {+  const parsed = Date.parse(n)+  const $ref = new Date()++  $ref.setTime(parsed)++  return (+    (typeof parsed === 'number' &&+      parsed !== NaN &&+      parsed > 0 &&+      String(parsed).length === 13 &&+      $ref) ||+    null+  )+}++/**+ *+ */++export function serializeDate(n: string) {+  const date = toDate(n)+  return date && date.toJSON()+}++/**+ * verify that a vriable contains a safe date/date-time string+ */++export function isSafeDate(n: string): boolean {+  const date = toDate(n)+  return date !== null && date.getTime() !== NaN+}++/**+ *+ */++export function isURL(s: string): boolean {+  let res = null+  const urlRegex = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z0-9]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g

@isocroft Sounds good, but let's add the link with the SO discussion in a comment on top of this function for reference.

isocroft

comment created time in 2 months

push eventErikWittern/graphql-demo

Erik Wittern

commit sha 5c8dfa7602680b2af36bac4909a57c1ebf09653f

Switch to PR data

view details

push time in 2 months

push eventErikWittern/graphql-demo

Erik Wittern

commit sha 153a903741bf761e2c7d07cfbc615f83a92c7654

Better name for input element

view details

push time in 2 months

push eventErikWittern/graphql-demo

Erik Wittern

commit sha d75a46eb3ffe8d9536a13f83fcf1737a6f7dc882

Improve readme

view details

push time in 2 months

push eventErikWittern/graphql-demo

Erik-Wittern

commit sha 7e16087729363976e4f4e53512a6da352f97c414

Add implementation

view details

push time in 2 months

push eventErikWittern/graphql-demo

Erik-Wittern

commit sha 387478b01c834ab618a27436cfbec8ae13f9a036

Add implementation

view details

push time in 2 months

create barnchErikWittern/graphql-demo

branch : master

created branch time in 2 months

created repositoryErikWittern/graphql-demo

Example GraphQL app that renders latest issues and issue comments for a given GitHub repository.

created time in 2 months

pull request commentIBM/openapi-to-graphql

added stricter scalar type checks

@isocroft I think this is a really nice PR, thank you very much! I love the idea of having stricter checks for scalars, and also making use of the information about the nature values that could already be defined in an OpenAPI document.

I wanted to ask about the choice of https://github.com/joonhocho/graphql-scalar as a new dependency, though. There seem to be more popular GraphQL scalar libraries, which seem more actively maintained, like https://github.com/Urigo/graphql-scalars. Would they offer the same functionality required by this PR?

The current dependency also introduces a peerDependency for https://github.com/Microsoft/tslib. tslib itself has no dependencies, and comes from the makers of TypeScript, so I don't have many concerns about it. Just would like to understand the choice of https://github.com/joonhocho/graphql-scalar better.

isocroft

comment created time in 2 months

pull request commentIBM/openapi-to-graphql

Replace request with isomorphic-unfetch

@JsonKim @Alan-Cha I guess one starting point is to look at the list of alternative libraries that the request team itself compiled: https://github.com/request/request/issues/3143

JsonKim

comment created time in 2 months

issue closedErikWittern/openapi-snippet

OpenAPISnippets let over const

https://github.com/ErikWittern/openapi-snippet/blame/d31d79a19a22a3f08285f46fab81d8d63fc6299f/index.js#L202

const OpenAPISnippets = window.OpenAPISnippets || {} <------- let over const

// define that object OpenAPISnippets = { getSnippets, getEndpointSnippets }

can you fix issue where you can't redefine OpenAPISnippets because it's const and it fails of readonly property.

closed time in 2 months

povilass

issue commentErikWittern/openapi-snippet

OpenAPISnippets let over const

@povilass Thanks for filing the issue, and @joe642 for the PR! I released a new version with the fix: https://github.com/ErikWittern/openapi-snippet/releases/tag/v0.8.1

povilass

comment created time in 2 months

created tagErikWittern/openapi-snippet

tagv0.8.1

Generates code snippets for given Swagger / Open API specification files.

created time in 2 months

release ErikWittern/openapi-snippet

v0.8.1

released time in 2 months

push eventErikWittern/openapi-snippet

Erik-Wittern

commit sha 8d46db5a15a05eb507afa13289a03b459a40e165

Update version Signed-off-by: Erik-Wittern <erik.wittern@ibm.com>

view details

push time in 2 months

pull request commentErikWittern/openapi-snippet

Fix assignment to constant in index.js

@joe642 Thanks for the PR - I was quite busy and didn't have an opportunity to address the issue myself, so thank you!

joe642

comment created time in 2 months

push eventErikWittern/openapi-snippet

Joe Tomlinson

commit sha c8bd7eab4ed345fdec2fb840ca2934f7fbc448cc

Fix assignment to constant in index.js

view details

Erik Wittern

commit sha b745d6085d31a7f816ef187569442bc7b68ddfa9

Merge pull request #41 from joe642/patch-1 Fix assignment to constant in index.js

view details

push time in 2 months

PR merged ErikWittern/openapi-snippet

Fix assignment to constant in index.js

Fixes issue #36

+1 -1

0 comment

1 changed file

joe642

pr closed time in 2 months

push eventErikWittern/oasgraph

Erik Wittern

commit sha 46d36efe06374f79ee4bc7b37cff15d1ce55d841

Describe subscription support Signed-off-by: Erik-Wittern <erik.wittern@ibm.com>

view details

push time in 3 months

PR opened IBM/openapi-to-graphql

Describe subscription support
+4 -0

0 comment

1 changed file

pr created time in 3 months

push eventErikWittern/oasgraph

Erik Wittern

commit sha b69bce6de01109b249782d28d9d2b424f7a76967

Describe subscription support

view details

push time in 3 months

more