Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
strip out the string format that we do not support.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolodya committed Apr 4, 2019
1 parent 7963c65 commit fd8aba3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion example/swagger-files/petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@
"in": "formData",
"description": "Updated name of the pet",
"required": false,
"type": "string"
"type": "string",
"format": "some-unknown-format"
}, {
"name": "status",
"in": "formData",
Expand Down
21 changes: 21 additions & 0 deletions packages/api-explorer/src/form-components/SchemaField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ function getDefaultNumFormat(type) {
return '';
}

function doesFormatExist(type, format) {
const availableFormats = [
'int64',
'int32',
'double',
'float',
'binary',
'byte',
'string',
'uuid',
'duration',
'dateTime',
'integer',
'json',
];

return type === 'string' && availableFormats.includes(format);
}

function isNumType(schema, type, format) {
schema.format = schema.format || getDefaultNumFormat(schema.type);
return schema.type === type && schema.format.match(format);
Expand All @@ -28,6 +47,8 @@ function getCustomType(schema) {
}

function SchemaField(props) {
if (!doesFormatExist(props.schema.type, props.schema.format)) props.schema.format = undefined;

if (props.schema.readOnly) {
// Maybe use this when it's been merged?
// Though that just sets `input[readonly]` which still shows
Expand Down

0 comments on commit fd8aba3

Please sign in to comment.