This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This makes styling booleans so much easier as they just inherit dropdown styles
- Loading branch information
Dom Harrington
committed
Aug 8, 2018
1 parent
8c39550
commit cc7eafb
Showing
3 changed files
with
25 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const React = require('react'); | ||
const extensions = require('@readme/oas-extensions'); | ||
|
||
const SchemaField = require('react-jsonschema-form/lib/components/fields/SchemaField').default; | ||
|
||
function createSchemaField(oas) { | ||
const explorerEnabled = oas[extensions.EXPLORER_ENABLED]; | ||
|
||
return function (props) { | ||
// if (!explorerEnabled) { | ||
// props.uiSchema = Object.assign(props.uiSchema, { "ui:options": { addable: false }}) | ||
// }; | ||
|
||
if (props.schema.type === 'boolean') { | ||
props.schema.enumNames = ['true', 'false'] | ||
return <SchemaField {...props} uiSchema={{ "ui:widget": "select" }} /> | ||
} | ||
return <SchemaField {...props} /> | ||
} | ||
} | ||
|
||
module.exports = createSchemaField; |