@digi-frontend/dgate-api-documentation 1.0.33 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digi-frontend/dgate-api-documentation",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "main": "dist/src/index.js",
5
5
  "module": "dist/src/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -69,9 +69,12 @@ const LivePreview: React.FC<LivePreviewProps> = ({ transformedData }) => {
69
69
  rel="noopener noreferrer"
70
70
  target="_blank"
71
71
  >
72
+ {item?.externalDocs?.url && !item?.externalDocs?.description
73
+ ? item?.externalDocs?.url
74
+ : null}
72
75
  {item?.externalDocs?.description
73
76
  ? item?.externalDocs?.description?.substring(0, 12)
74
- : '-'}
77
+ : !item?.externalDocs?.url ? '-': null}
75
78
  {item?.externalDocs?.description && item?.externalDocs?.description?.length > 12
76
79
  ? '...'
77
80
  : ''}
@@ -104,6 +107,10 @@ const LivePreview: React.FC<LivePreviewProps> = ({ transformedData }) => {
104
107
  }))
105
108
  }
106
109
 
110
+ const securityScheme = !!securityKey
111
+ ? securitySchemes[securityKey].scheme || securitySchemes[securityKey].type
112
+ : '-'
113
+
107
114
  return (
108
115
  <div className={styles.livePreviewContainer}>
109
116
  <div className="row">
@@ -116,9 +123,9 @@ const LivePreview: React.FC<LivePreviewProps> = ({ transformedData }) => {
116
123
  key={'APIAuthenticationType'}
117
124
  label={'API authentication type: '}
118
125
  value={
119
- !!securityKey
120
- ? securitySchemes[securityKey].scheme || securitySchemes[securityKey].type
121
- : '-'
126
+ !!securityScheme && securityScheme.toLowerCase() === 'public'
127
+ ? 'Keyless'
128
+ : securityScheme
122
129
  }
123
130
  />
124
131
  <SimpleLabelValue key={'version'} label={'Version: '} value={info?.version || '-'} />
@@ -443,7 +443,6 @@ const MethodsAccordion = ({
443
443
  const currentResIndex = method.responses.findIndex(
444
444
  (res) => res.code === currentResponse.code
445
445
  )
446
-
447
446
  if (currentResIndex !== -1) {
448
447
  setFieldValue(
449
448
  `responses[${currentResIndex}].content.schema.properties`,
@@ -466,7 +465,7 @@ const MethodsAccordion = ({
466
465
  setFieldValue('responses', clonedResponses)
467
466
  }
468
467
  }}
469
- onValidation={() => null}
468
+ onValidation={(valid) => null}
470
469
  />
471
470
  }
472
471
  />
@@ -113,6 +113,18 @@ export const transformPathsToArray = (paths: OpenAPIFile['paths']): TransformedP
113
113
  return transformedPaths
114
114
  }
115
115
 
116
+ const validateBodyForResponse = (content, method) => {
117
+ let _content = JSON.parse((content?.schema as any)?.properties as string)
118
+ if (method == 'get') {
119
+ if (!_content?.body) {
120
+ _content = {
121
+ body: _content,
122
+ }
123
+ }
124
+ }
125
+ return _content
126
+ }
127
+
116
128
  export const transformPathsArrayToOrigin = (paths: TransformedPathsArray): OpenAPIFile['paths'] => {
117
129
  return paths.reduce((acc, { path, methods }) => {
118
130
  acc[path] = methods.reduce((methodAcc, { type, tags, responses, requestBody, ...rest }) => {
@@ -128,7 +140,7 @@ export const transformPathsArrayToOrigin = (paths: TransformedPathsArray): OpenA
128
140
  [content.contentType]: {
129
141
  schema: {
130
142
  ...(content.schema as object),
131
- properties: JSON.parse((content?.schema as any)?.properties as string),
143
+ properties: validateBodyForResponse(content, type),
132
144
  },
133
145
  },
134
146
  }