Comments (4)
@drwpow thanks for pointing me to redocly. It seems like there are issues in the generated openapi.json. I will close this issue for now and if I can resolve the lints and the issue persists, I will reopen it.
from openapi-typescript.
In OpenAPI 3, Media types (e.g. application/json
) should have a schema
property that points to the actual data shape. Without this it’s invalid. Does your OpenAPI schema have this? Also, does your schema throw any errors in validation (run through Redocly CLI)?
from openapi-typescript.
I'm using rust's aide crate to generate my schema, so I hope that's generated correctly.
This is my openapi.json path:
"/api/events/{id}": {
"get": {
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/Event"
},
{
"type": "null"
}
]
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
}
},
And this is the referenced component schema:
"Event": {
"type": "object",
"required": [
"created",
"end",
"id",
"name",
"owner_id",
"slug",
"start",
"updated",
"visible"
],
"properties": {
"coverimage_id": {
"type": [
"string",
"null"
],
"format": "uuid"
},
"created": {
"type": "string",
"format": "date-time"
},
"description": {
"type": [
"string",
"null"
]
},
"end": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "string",
"format": "uuid"
},
"location": {
"type": [
"string",
"null"
]
},
"name": {
"type": "string"
},
"owner_id": {
"type": "string",
"format": "uuid"
},
"password_hash": {
"type": [
"string",
"null"
]
},
"slug": {
"type": "string"
},
"start": {
"type": "string",
"format": "date-time"
},
"updated": {
"type": "string",
"format": "date-time"
},
"visible": {
"type": "boolean"
},
"website": {
"type": [
"string",
"null"
]
}
}
},
For reference, here is my complete openapi.json:
{
"openapi": "3.1.0",
"info": {
"title": "",
"version": ""
},
"paths": {
"/api/query/list_events": {
"get": {
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PublicEvent"
}
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/api/query/list_users": {
"get": {
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PublicUser"
}
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/api/events/": {
"get": {
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ReadEvent"
}
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
},
"post": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/EventCreateBody"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Event"
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/api/events/{id}": {
"get": {
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/Event"
},
{
"type": "null"
}
]
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/api/images/": {
"get": {
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Image"
}
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
},
"post": {
"requestBody": {
"description": "multipart form data",
"content": {
"multipart/form-data": {
"schema": {
"type": "array"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/api/images/{id}": {
"get": {
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/Image"
},
{
"type": "null"
}
]
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/api/images/s3/*path": {
"get": {
"responses": {
"500": {
"description": "Internal Server Error"
}
}
}
},
"/api/users/": {
"get": {
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ReadUser"
}
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/api/users/{id}": {
"get": {
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/ReadUser"
},
{
"type": "null"
}
]
}
}
}
},
"500": {
"description": "Internal Server Error"
}
}
}
}
},
"components": {
"schemas": {
"Event": {
"type": "object",
"required": [
"created",
"end",
"id",
"name",
"owner_id",
"slug",
"start",
"updated",
"visible"
],
"properties": {
"coverimage_id": {
"type": [
"string",
"null"
],
"format": "uuid"
},
"created": {
"type": "string",
"format": "date-time"
},
"description": {
"type": [
"string",
"null"
]
},
"end": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "string",
"format": "uuid"
},
"location": {
"type": [
"string",
"null"
]
},
"name": {
"type": "string"
},
"owner_id": {
"type": "string",
"format": "uuid"
},
"password_hash": {
"type": [
"string",
"null"
]
},
"slug": {
"type": "string"
},
"start": {
"type": "string",
"format": "date-time"
},
"updated": {
"type": "string",
"format": "date-time"
},
"visible": {
"type": "boolean"
},
"website": {
"type": [
"string",
"null"
]
}
}
},
"EventCreateBody": {
"type": "object",
"required": [
"end",
"name",
"owner_id",
"slug",
"start",
"visible"
],
"properties": {
"coverimage_id": {
"type": [
"string",
"null"
],
"format": "uuid"
},
"description": {
"type": [
"string",
"null"
]
},
"end": {
"type": "string",
"format": "date-time"
},
"location": {
"type": [
"string",
"null"
]
},
"name": {
"type": "string"
},
"owner_id": {
"type": "string",
"format": "uuid"
},
"password_hash": {
"type": [
"string",
"null"
]
},
"slug": {
"type": "string"
},
"start": {
"type": "string",
"format": "date-time"
},
"visible": {
"type": "boolean"
},
"website": {
"type": [
"string",
"null"
]
}
}
},
"Image": {
"type": "object",
"required": [
"hash",
"hidden",
"id",
"keywords",
"metadata",
"photographer_id",
"size",
"uploaded"
],
"properties": {
"created": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"event_id": {
"type": [
"string",
"null"
],
"format": "uuid"
},
"hash": {
"type": "string"
},
"hidden": {
"type": "boolean"
},
"id": {
"type": "string",
"format": "uuid"
},
"keywords": {
"type": "array",
"items": {
"type": "string"
}
},
"metadata": true,
"photographer_id": {
"type": "string",
"format": "uuid"
},
"size": {
"type": "integer",
"format": "int32"
},
"upload_completed": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"upload_filename": {
"type": [
"string",
"null"
]
},
"uploaded": {
"type": "string",
"format": "date-time"
}
}
},
"PublicEvent": {
"type": "object",
"required": [
"created",
"end",
"id",
"name",
"owner",
"slug",
"start",
"updated",
"visible"
],
"properties": {
"coverimage_id": {
"type": [
"string",
"null"
],
"format": "uuid"
},
"created": {
"type": "string",
"format": "date-time"
},
"description": {
"type": [
"string",
"null"
]
},
"end": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "string",
"format": "uuid"
},
"location": {
"type": [
"string",
"null"
]
},
"name": {
"type": "string"
},
"owner": {
"$ref": "#/components/schemas/PublicUser"
},
"slug": {
"type": "string"
},
"start": {
"type": "string",
"format": "date-time"
},
"updated": {
"type": "string",
"format": "date-time"
},
"visible": {
"type": "boolean"
},
"website": {
"type": [
"string",
"null"
]
}
}
},
"PublicUser": {
"type": "object",
"required": [
"created",
"display_name",
"id",
"is_admin",
"username"
],
"properties": {
"created": {
"type": "string",
"format": "date-time"
},
"display_name": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"image_id": {
"type": [
"string",
"null"
],
"format": "uuid"
},
"is_admin": {
"type": "boolean"
},
"username": {
"type": "string"
}
}
},
"ReadEvent": {
"type": "object",
"required": [
"created",
"end",
"id",
"name",
"owner_id",
"slug",
"start",
"updated",
"visible"
],
"properties": {
"coverimage_id": {
"type": [
"string",
"null"
],
"format": "uuid"
},
"created": {
"type": "string",
"format": "date-time"
},
"description": {
"type": [
"string",
"null"
]
},
"end": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "string",
"format": "uuid"
},
"location": {
"type": [
"string",
"null"
]
},
"name": {
"type": "string"
},
"owner_id": {
"type": "string",
"format": "uuid"
},
"slug": {
"type": "string"
},
"start": {
"type": "string",
"format": "date-time"
},
"updated": {
"type": "string",
"format": "date-time"
},
"visible": {
"type": "boolean"
},
"website": {
"type": [
"string",
"null"
]
}
}
},
"ReadUser": {
"type": "object",
"required": [
"created",
"display_name",
"id",
"is_admin",
"username"
],
"properties": {
"created": {
"type": "string",
"format": "date-time"
},
"display_name": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"image_id": {
"type": [
"string",
"null"
],
"format": "uuid"
},
"is_admin": {
"type": "boolean"
},
"last_login": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"username": {
"type": "string"
}
}
}
}
}
}
from openapi-typescript.
Sounds good! Yeah with 6.x and below we didn’t have the ability to validate schemas because it’s basically a whole separate problem and project. But the upcoming 7.x (next
) version does validate via Redocly because this has been a common sticking point (it’s complete for the most part, just needs a few more bugfixes to ship the stable version)
from openapi-typescript.
Related Issues (20)
- Response types from openapi-fetch ignore null values
- Multiple security schemes not supported
- With React Query: Invariant: headers() expects to have requestAsyncStorage, none available. HOT 3
- `--properties-required-by-default` and `--default-non-nullable` flags do not work HOT 2
- Nested object's properties are mapped to unknown, but in OpenAPI they are typed correctly HOT 3
- "AdditionalProperties" reflects onto existing properties and causes TypeScript compile errors HOT 1
- Issues with references (`$ref`) resolution HOT 2
- Error with negative numbers in enums HOT 2
- Allow for custom types in path params serialization (and maybe other places serialization too)
- Types derived for oneOf construct result in TS2502 error HOT 7
- Uncaught error when body is `undefined` in request init HOT 6
- issue on - generate client when yaml has mutiple same external ref
- Generate subset of schema
- Deduplicate enums
- `type: object` generating `Record<string, never>` HOT 1
- Throw error on error and data property be defined HOT 3
- [v7] transform + nullable issue with Identifier with Node.js API HOT 1
- Is there a plan to support cookie parameters? HOT 2
- discriminator mapping ignored when using allOf with oneOf HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-typescript.