mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-03 20:17:59 +00:00 
			
		
		
		
	UI: Parse OpenAPI response correctly if schema includes $ref (#14508)
* Parse OpenAPI response correctly if schema includes * Add changelog * small cleanup
This commit is contained in:
		
							
								
								
									
										3
									
								
								changelog/14508.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								changelog/14508.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					```release-note:improvement
 | 
				
			||||||
 | 
					ui: Parse schema refs from OpenAPI
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
@@ -204,10 +204,18 @@ export default Service.extend({
 | 
				
			|||||||
        };
 | 
					        };
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // TODO: handle post endpoints without requestBody
 | 
					      let props = {};
 | 
				
			||||||
      const props = pathInfo.post
 | 
					      const schema = pathInfo?.post?.requestBody?.content['application/json'].schema;
 | 
				
			||||||
        ? pathInfo.post.requestBody.content['application/json'].schema.properties
 | 
					      if (schema.$ref) {
 | 
				
			||||||
        : {};
 | 
					        // $ref will be shaped like `#/components/schemas/MyResponseType
 | 
				
			||||||
 | 
					        // which maps to the location of the item within the openApi response
 | 
				
			||||||
 | 
					        let loc = schema.$ref.replace('#/', '').split('/');
 | 
				
			||||||
 | 
					        props = loc.reduce((prev, curr) => {
 | 
				
			||||||
 | 
					          return prev[curr] || {};
 | 
				
			||||||
 | 
					        }, help.openapi).properties;
 | 
				
			||||||
 | 
					      } else if (schema.properties) {
 | 
				
			||||||
 | 
					        props = schema.properties;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      // put url params (e.g. {name}, {role})
 | 
					      // put url params (e.g. {name}, {role})
 | 
				
			||||||
      // at the front of the props list
 | 
					      // at the front of the props list
 | 
				
			||||||
      const newProps = assign({}, paramProp, props);
 | 
					      const newProps = assign({}, paramProp, props);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user