我做了一个openapi规范,我们使用它生成代码BE和FE。它工作得很好,但是给了我一个关于我的模式类型的警告。然后默认为“object”,这就是它工作的原因,但这不是一个好的解决方案。
请看一看代码,并帮助我看到一些(明显的)我在这里遗漏的东西。谢谢。错误:
[main] INFO o.o.c.l.TypeScriptAngularClientCodegen - generating code for Angular 11.0.0 ...
[main] INFO o.o.c.l.TypeScriptAngularClientCodegen - (you can select the angular version by setting the additionalProperty ngVersion)
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] INFO o.o.codegen.TemplateManager - writing file /home/chai/Nextcloud/Documents/nerdspul/werkspul/dev-division/mosar/src/frontend/mosar-frontend/./build/openapi/model/./flashcard.ts
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - #components/schemas/Flashcard is not defined
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - #components/schemas/Flashcard is not defined
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.DefaultCodegen - Error obtaining the datatype from ref:#components/schemas/Flashcard. Default to 'object'
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - #components/schemas/Flashcard is not defined
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.DefaultCodegen - Error obtaining the datatype from ref:#components/schemas/Flashcard. Default to 'object'
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - #components/schemas/Flashcard is not defined
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.DefaultCodegen - Error obtaining the datatype from ref:#components/schemas/Flashcard. Default to 'object'
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.utils.ModelUtils - #components/schemas/Flashcard is not defined
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard
[main] WARN o.o.codegen.DefaultCodegen - Error obtaining the datatype from ref:#components/schemas/Flashcard. Default to 'object'
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: #components/schemas/Flashcard守则如下:
openapi: '3.0.0'
servers:
# - url: http://localhost:8080/api
# mockapi.io
- url: https://6071a9e850aaea0017284e9d.mockapi.io/api
info:
version: 1.0.0
title: Flashcard API
paths:
/flashcard/{id}:
get:
tags:
- FlashcardApi
description: Returns a single flashcard by id.
operationId: getFlashcard
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
200:
$ref: '#/components/schemas/Flashcard'
404:
description: Flashcard does not exist.
500:
description: A server error occurred.
/flashcard:
post:
tags:
- FlashcardApi
description: Saves a single flashcard in the db.
operationId: createFlashcard
requestBody:
description: Json object to create a flashcard
required: true
content:
application/json:
schema:
$ref: '#components/schemas/Flashcard'
responses:
200:
description: A flashcard.
content:
application/json:
schema:
$ref: '#/components/schemas/Flashcard'
404:
description: Flashcard does not exist.
500:
description: A server error occurred.
components:
schemas:
Flashcard:
type: object
properties:
term:
type: string
explanation:
type: string
id:
type: string
createDate:
type: string
changeDate:
type: string
createdBy:
type: string
changedBy:
type: string
required:
- term
- explanation发布于 2021-05-25 14:24:29
更改:$ref: '#components/schemas/Flashcard' to:$ref: '#/components/schemas/Flashcard' (您错过了/)
还将其添加到第一个get (/flashcard/{id}:)中,以返回正确的类型:
responses:
200:
description: flash card
content:
application/json:
schema:
$ref: '#/components/schemas/Flashcard'https://stackoverflow.com/questions/67688676
复制相似问题