File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed
packages/docusaurus-theme-openapi-docs/src/theme/ApiItem Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,7 @@ paths:
206206 application/xml :
207207 schema :
208208 $ref : " #/components/schemas/Pet"
209+
209210 " 400 " :
210211 description : Invalid ID supplied
211212 " 404 " :
Original file line number Diff line number Diff line change @@ -101,7 +101,6 @@ const sidebars = {
101101 ] ,
102102 } ,
103103 ] ,
104-
105104 "petstore-2.0.0" : [
106105 {
107106 type : "html" ,
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ export default function ApiItem(props: Props): JSX.Element {
5353 const options = themeConfig . api ;
5454 const isBrowser = useIsBrowser ( ) ;
5555
56+ // Regex for 2XX status
57+ const statusRegex = new RegExp ( "(20[0-9]|2[1-9][0-9])" ) ;
58+
5659 // Define store2
5760 let store2 : any = { } ;
5861 const persistanceMiddleware = createPersistanceMiddleware ( options ) ;
@@ -64,13 +67,15 @@ export default function ApiItem(props: Props): JSX.Element {
6467
6568 // Init store for CSR to hydrate components
6669 if ( isBrowser ) {
67- const acceptArray = Array . from (
68- new Set (
69- Object . values ( api ?. responses ?? { } )
70- . map ( ( response : any ) => Object . keys ( response . content ?? { } ) )
71- . flat ( )
72- )
73- ) ;
70+ // Create list of only 2XX response content types to create request samples from
71+ let acceptArray : any = [ ] ;
72+ for ( const [ code , content ] of Object . entries ( api ?. responses ?? [ ] ) ) {
73+ if ( statusRegex . test ( code ) ) {
74+ acceptArray . push ( Object . keys ( content . content ?? { } ) ) ;
75+ }
76+ }
77+ acceptArray = acceptArray . flat ( ) ;
78+
7479 const content = api ?. requestBody ?. content ?? { } ;
7580 const contentTypeArray = Object . keys ( content ) ;
7681 const servers = api ?. servers ?? [ ] ;
You can’t perform that action at this time.
0 commit comments