[OpenAPI] user-defined scalar type with nullable #4543
Unanswered
akishichinibu
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Does the tool also complain if it was of this form with openapi: 3.0.0
info:
title: (title)
version: 0.0.0
tags: []
paths: {}
components:
schemas:
A:
type: object
required:
- x
properties:
x:
oneOf:
- $ref: '#/components/schemas/MyStr'
nullable: true
MyStr:
type: string Just doing some reading on the spec, it does indeed say that nullable is only applicable when type is specified but this is a but problematic for openapi3 and most reference I found recommend to use the approach above |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://typespec.io/playground?c=c2NhbGFyIE15U3RyIGV4dGVuZHMgc3RyaW5nOwoKbW9kZWwgQSB7CiAgeDrHJnwgbnVsbAp9Cg%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D
Consider the following TypeSpec definition:
This generates the following OpenAPI specification, which violates the Redoc rule
spec
.In this case, the error occurs because the
nullable
field is used without defining thetype
explicitly within theoneOf
clause, which Redoc requires for proper validation.How can I fix this?
Beta Was this translation helpful? Give feedback.
All reactions