feat: add components for individual schema properties [KHCP-11732]#38
Conversation
src/utils/property-field.ts
Outdated
| @@ -0,0 +1,74 @@ | |||
| import type { SchemaObject } from '@/types' | |||
| import { isValidSchemaObject } from '@/utils' | |||
| import PropertyDescription from '@/components/document/property-fields/PropertyDescription.vue' | |||
There was a problem hiding this comment.
This is do not like: utils importing components ....
There was a problem hiding this comment.
Fixed. Moved it to be a computed property inside ModelProperty
| :key="propertyName" | ||
| :data-testid="`model-property-${propertyName}`" | ||
| :property="property" | ||
| :property-name="propertyName.toString()" |
There was a problem hiding this comment.
Background:
#33 (comment)
if the type of propertyName is a string, why do we need toString here?
@adamdehaven turns out it's because openapi3-ts has typed properties as a mapped type { [propertyName: string]: SchemaObject | ReferenceObject }, instead of a Record<string, SchemaObject | ReferenceObject>
It's a known TS quirk that keys in a mapped type will always be interpreted as string | number. Ref: microsoft/TypeScript#48269
There was a problem hiding this comment.
Have opened a PR in openapi3-ts to fix this
46ccf15 to
da34600
Compare
# [1.3.0](v1.2.1...v1.3.0) (2024-05-07) ### Features * add components for individual schema properties [KHCP-11732] ([#38](#38)) ([c11b469](c11b469))
|
🎉 This PR is included in version 1.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Here is an example
SchemaObject:here,
nameis one of the properties of thesampleSchemaObject. Thenameproperty has fields liketype,description,enum,example, etc.This PR aims to add individual components for these fields of the property of a Schema Object.
Changes
ModelPropertiescomponent →ModelPropertiescomponent toModelProperty, since now it handles a singlepropertyinstead of the entirepropertiesobjectdetail-summaryorderedFieldListutil to fix the order in which fields are renderedutils/schema-model.ts