File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed
Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -298,6 +298,7 @@ export const OpenAPIPath = ({
298298 key = { ref }
299299 schema = { ref }
300300 openapiPath = { openapiPath }
301+ isCommonRef = { false }
301302 collectRefs = { false }
302303 />
303304 )
Original file line number Diff line number Diff line change @@ -20,6 +20,17 @@ export interface OpenAPIRefProps {
2020 * The specific path to the OpenAPI schema, otherwise the first matched will be used.
2121 */
2222 openapiPath ?: string
23+ /**
24+ * Whether is a common reference, no `uid` will be generated.
25+ *
26+ * @default true
27+ */
28+ isCommonRef ?: boolean
29+ /**
30+ * Whether to collect references from the schema.
31+ *
32+ * @default true
33+ */
2334 collectRefs ?: boolean
2435}
2536
@@ -150,6 +161,7 @@ const getRefsForSchema = (
150161export const OpenAPIRef = ( {
151162 schema,
152163 openapiPath : openapiPath_ ,
164+ isCommonRef = true ,
153165 collectRefs = true ,
154166} : OpenAPIRefProps ) => {
155167 const { page } = usePageData ( )
@@ -158,7 +170,9 @@ export const OpenAPIRef = ({
158170
159171 const innerUid = useId ( )
160172
161- if ( ! uid ) {
173+ if ( isCommonRef ) {
174+ uid = '' // common references do not need a unique ID
175+ } else if ( ! uid ) {
162176 uid = innerUid
163177 }
164178
@@ -207,6 +221,7 @@ export const OpenAPIRef = ({
207221 key = { schema }
208222 schema = { schema }
209223 openapiPath = { openapiPath }
224+ isCommonRef = { isCommonRef }
210225 collectRefs = { false }
211226 />
212227 ) ) }
Original file line number Diff line number Diff line change @@ -14,7 +14,12 @@ export const RefLink = ({ $ref }: RefLinkProps) => {
1414 return null
1515 }
1616
17- const ref = $ref . replace ( '/components/schemas/' , '' ) . slice ( 1 )
18- const refName = modelName ( ref )
19- return < X . a href = { COMMON_REFS [ ref ] || `#${ uid } -${ ref } ` } > { refName } </ X . a >
17+ const ref = $ref . replace ( '/components/schemas/' , '' )
18+ const plainRef = ref . slice ( 1 )
19+ const refName = modelName ( plainRef )
20+ return (
21+ < X . a href = { COMMON_REFS [ plainRef ] || ( uid ? `#${ uid } -${ plainRef } ` : ref ) } >
22+ { refName }
23+ </ X . a >
24+ )
2025}
You can’t perform that action at this time.
0 commit comments