#1 Today 14:50:25

DirkH
Member
Registered: 2025-09-26
Posts: 9

Issue with Swagger/OpenAPI Client Generator

I ran into an Issue with the Swagger/OpenAPI Client Generator mopenapi from current Mormot 2.4 release.
It redefines typical FPC labels without hassitation...

In my case it redefined TLabel, wich is obviously a bad idea wink

There should be some mechanism / prefix to make sure typical fpc clases (label, edit etc.) are not overwritten.

I dont know if Im allowed to publish the full json, but this should be the critical part:

"Label": {
  "type": "object",
  "description": "Label that is used for entities like tags.",
  "properties": {
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "The date when the entity was created"
    },
    "createdBy": {
      "$ref": "#/components/schemas/UserReference"
    },
    "hidden": {
      "type": "boolean",
      "description": "Whether the label is hidden or not"
    },
    "id": {
      "type": "integer",
      "format": "int32",
      "description": "Id of the entity",
      "minimum": 0
    },
    "name": {
      "type": "string",
      "description": "Name of the entity"
    },
    "privateLabel": {
      "type": "boolean",
      "description": "Whether the label is private or not"
    }
  },
  "readOnly": true
}

Thanks and best regards
Dirk

Offline

#2 Today 15:52:38

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,512
Website

Re: Issue with Swagger/OpenAPI Client Generator

What about adding the unit names in the beginning as prefix of the type name?
This is how usually how type names collision is resolved in practice.

If we would try to detect some forbidden components names, we would need to be able to detect all components names, not only TLabel and TEdit.
So a huge list of forbidden identifiers is no option I guess.

So perhaps TOpenApiParser.DtoTypePrefix would help.
A prefix with T*SwaggerName could make them genuine - and more easy to spot.
Please try https://github.com/synopse/mORMot2/commit/f2d2974f

Offline

Board footer

Powered by FluxBB