-
Notifications
You must be signed in to change notification settings - Fork 251
feat(docs): bring new JSV into Elements #979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
10baf4d
7c0747b
b3686e9
ef1d6f4
7a7a547
400b006
e446dd9
afc1fec
ce63942
eaaf4c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import { Select } from '@stoplight/mosaic'; | ||
| import { JsonSchemaViewer } from '@stoplight/json-schema-viewer'; | ||
| import { Box, Select } from '@stoplight/mosaic'; | ||
| import { IHttpOperationRequestBody } from '@stoplight/types'; | ||
| import { JSONSchema4 } from 'json-schema'; | ||
| import * as React from 'react'; | ||
|
|
||
| import { isJSONSchema } from '../../../utils/guards'; | ||
| import { MarkdownViewer } from '../../MarkdownViewer'; | ||
| import { SchemaViewer } from '../../SchemaViewer'; | ||
| import { SubSectionPanel } from '../Sections'; | ||
| import { getExamplesObject } from './utils'; | ||
|
|
||
| export interface BodyProps { | ||
| body: IHttpOperationRequestBody; | ||
|
|
@@ -25,7 +25,6 @@ export const Body = ({ body: { contents = [], description }, onChange }: BodyPro | |
| if (contents.length === 0 && !description) return null; | ||
|
|
||
| const schema = contents[chosenContent]?.schema; | ||
| const examples = getExamplesObject(contents[chosenContent]?.examples || []); | ||
|
|
||
| return ( | ||
| <SubSectionPanel | ||
|
|
@@ -42,7 +41,11 @@ export const Body = ({ body: { contents = [], description }, onChange }: BodyPro | |
| > | ||
| {description && <MarkdownViewer className="mb-6" markdown={description} />} | ||
|
|
||
| {isJSONSchema(schema) && <SchemaViewer className="mt-6" schema={schema} examples={examples} viewMode="write" />} | ||
| {isJSONSchema(schema) && ( | ||
| <Box ml={-9}> | ||
| <JsonSchemaViewer schema={schema as JSONSchema4} viewMode="write" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we casting here? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, sometimes we use our SchemaViewer wrapper, sometimes we use JSV directly. What is the logic behind that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me answer the 2nd question first:
Now the cast: To be honest, I don't know. I simply copied the rendering of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case I would think about renaming There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about that, but didn't want to expand the scope too much. If you think that's fine, I'll do it now! |
||
| </Box> | ||
| )} | ||
| </SubSectionPanel> | ||
| ); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import { PropertyTypeColors } from '@stoplight/json-schema-viewer'; | ||
| import { VStack } from '@stoplight/mosaic'; | ||
| import { Dictionary, HttpParamStyles, IHttpParam, Primitive } from '@stoplight/types'; | ||
| import { Tag } from '@stoplight/ui-kit'; | ||
|
|
@@ -50,7 +49,7 @@ export const Parameters: React.FunctionComponent<ParametersProps> = ({ parameter | |
|
|
||
| return ( | ||
| <VStack spacing={4} divider> | ||
| {sortBy(parameters, ['required', 'name']).map((parameter, index) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we remove sorting by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did I? I believe that was simply an unused argument so I simply removed it. |
||
| {sortBy(parameters, ['required', 'name']).map(parameter => { | ||
| const resolvedSchema = | ||
| parameter.schema?.$ref && resolveRef | ||
| ? resolveRef({ pointer: parameter.schema.$ref, source: null }, null, {}) | ||
|
|
@@ -107,7 +106,7 @@ export const Parameter: React.FunctionComponent<IParameterProps> = ({ parameter, | |
| <div className="HttpOperation__Parameters"> | ||
| <div className="flex items-center"> | ||
| <div className="font-medium font-mono">{parameter.name}</div> | ||
| <div className={cn('ml-2 text-sm', PropertyTypeColors[type])}>{format ? `${type}<${format}>` : type}</div> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the minimalistic unicolor look 😎 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, was that supposed to be changed too? I know it matches jsv types and I like it this way. Just wondering if that's the planned thing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is all grayscale, see here: https://www.figma.com/file/IkNc59AU2JN5Kc1qbd2AiB/Elements?node-id=157%3A0 So it was planned for in the design. It wasn't planned to be done in this issue (the issues don't quite cover the design changes fully, actually), but as JSV removed the colors it also removed the re muting: good idea, thanks, I'll fix that! |
||
| <div className={'ml-2 text-sm'}>{format ? `${type}<${format}>` : type}</div> | ||
| {parameterType !== 'path' && ( | ||
| <div | ||
| className={cn('ml-2 text-sm', { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to these now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above, examples are now being rendered by the Response Examples component on the right.