-
-
Notifications
You must be signed in to change notification settings - Fork 974
Closed
Description
Great work on the new allOf
rewrite. It generates nearly identical types to the workaround I mentioned here #531 (comment). However, it does not seem to respect the required section for referenced properties. Using the below partial schema:
schemas:
id:
type: string
title: id
description: Unique identifier for the given resource.
pattern: '^[a-zA-Z0-9]+$'
example: 1qyOUSitRuN5QPSFfVg6AuiUuzF
x-go-type: ksuid.KSUID
minLength: 27
maxLength: 27
readOnly: true
User:
title: User
allOf:
- type: object
properties:
id:
$ref: '#/components/schemas/id'
required:
- id
- $ref: '#/components/schemas/UserProperties'
- type: object
required:
- email
- name
- photo
- verified
We can see it generates the following type:
// User defines model for User.
type User struct {
Email openapi_types.Email `json:"email"`
// Unique identifier for the given resource.
Id *Id `json:"id,omitempty"`
// Contains the full name.
Name string `json:"name"`
// Link to the gravatar profile photo.
Photo string `json:"photo"`
Verified bool `json:"verified"`
}
Where Email
, Name
, Photo
, and Verified
are required but Id
is not. Maybe there is some configuration I am missing or this use-case hasn't been taken into account.
Metadata
Metadata
Assignees
Labels
No labels