Skip to content

Commit

Permalink
feat: render missed parts of JSON Schema (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
magicmatatjahu authored Oct 11, 2021
1 parent 4e4f9ae commit f38c0b1
Show file tree
Hide file tree
Showing 14 changed files with 6,779 additions and 1,886 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
test/output
output
sample
__transpiled
__transpiled
coverage
2 changes: 2 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Disable specific file since it would introduce more complexity to reduce it - mainly code complexity and complex template literals
sonar.exclusions=components/Schema.js,helpers/schema.js
8 changes: 3 additions & 5 deletions components/Channels.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Text } from "@asyncapi/generator-react-sdk";
import { SchemaHelpers } from "../helpers/schema";

import { Header } from "./common";
import { Message } from "./Message";
Expand Down Expand Up @@ -44,14 +45,11 @@ function Channel({ channelName, channel }) {
}

function Parameters({ parameters }) {
const params = Object.entries(parameters).map(([paramName, param]) => (
<Schema schema={param.schema()} schemaName={paramName} description={param.description()} hideTitle={true} />
));

const parametersSchema = SchemaHelpers.parametersToSchema(parameters);
return (
<Text>
<Header type={4}>Channel Parameters</Header>
{params}
<Schema schema={parametersSchema} hideTitle={true} />
</Text>
);
}
Expand Down
17 changes: 17 additions & 0 deletions components/Extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';

import { Schema } from './Schema';

import { SchemaHelpers } from '../helpers/schema';

export const Extensions = ({ name = 'Extensions', item }) => {
const extensions = SchemaHelpers.getCustomExtensions(item);
if (!extensions || !Object.keys(extensions).length) {
return null;
}

const schema = SchemaHelpers.jsonToSchema(extensions);
return (
<Schema schemaName={name} schema={schema} />
);
};
2 changes: 1 addition & 1 deletion components/Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ export function TermsOfService({ asyncapi }) {
<Link href={termsOfService}>{termsOfService}</Link>
</Text>
) : null;
}
}
Loading

0 comments on commit f38c0b1

Please sign in to comment.