Code Monkey home page Code Monkey logo

Comments (12)

digitaldogsbody avatar digitaldogsbody commented on July 16, 2024 2

That looks like it has fixed the issue with the _id and _type fields :)

from iiif-prezi3.

digitaldogsbody avatar digitaldogsbody commented on July 16, 2024 1

The other bug with LngString seems to persist, sadly

from iiif-prezi3.

koxudaxi avatar koxudaxi commented on July 16, 2024 1

@digitaldogsbody
Thank you for explaining the detail
I tried the command with the master branch version.
The problem is solved with the latest code.
I will release a new version within a few days.

$ pip install git+https://github.com/koxudaxi/datamodel-code-generator.git
# generated by datamodel-codegen:
#   filename:  iiif_3_0.json
#   timestamp: 2023-01-28T09:41:10+00:00

from __future__ import annotations

from datetime import datetime
from typing import Any, Dict, List, Optional, Union

from pydantic import AnyUrl, Extra, Field, PositiveFloat, PositiveInt, constr
...

class LngString(Base):
    __root__: Union[
        Dict[constr(regex=r'^[a-zA-Z-][a-zA-Z-]*$'), List[str]],
        Dict[constr(regex=r'^none$'), List[str]],
    ] = Field(
        ..., title='Language string, must have a language and value must be an array.'
    )

...

from iiif-prezi3.

digitaldogsbody avatar digitaldogsbody commented on July 16, 2024 1

Amazing, thank you so much!

from iiif-prezi3.

glenrobson avatar glenrobson commented on July 16, 2024

Looks like koxudaxi/datamodel-code-generator#917 doesn't fix our issues as it adds a prefix before the underscore e.g. field_id we want to remove the _ from the beginning.

from iiif-prezi3.

koxudaxi avatar koxudaxi commented on July 16, 2024

@glenrobson
OK. I will think about how to resolve the problem.

from iiif-prezi3.

koxudaxi avatar koxudaxi commented on July 16, 2024

@glenrobson
I have released the new version as 0.16.1
Could you please --remove-special-field-name-prefix as CLI option?
Thank you very much!!

from iiif-prezi3.

glenrobson avatar glenrobson commented on July 16, 2024

Thanks @koxudaxi we will run a test!

from iiif-prezi3.

koxudaxi avatar koxudaxi commented on July 16, 2024

@digitaldogsbody Thank you for testing it.

The other bug with LngString seems to persist, sadly

Could you please explain the problem?

from iiif-prezi3.

digitaldogsbody avatar digitaldogsbody commented on July 16, 2024

@koxudaxi Thanks so much for the responsive fixes - it makes a big difference to our project ☺️

The other issue is the one that @giacomomarchioro opened here: koxudaxi/datamodel-code-generator#696

In the types section of our schema, we have:

"lngString": {
            "title": "Language string, must have a language and value must be an array.",
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z-][a-zA-Z-]*$": {
                    "type": "array",
                    "items": { "type": "string"}
                },
                "^none$": {
                    "type": "array",
                    "items": { "type": "string"}
                }
            },
            "additionalProperties": false
        },

datamodel-code-generator (0.16.1) is creating:

class LngString(Base):
    pass

    class Config:
        extra = Extra.forbid

We are expecting something like:

class LngString(Base):
    __root__: Dict[str, List[str]]

    class Config:
        extra = Extra.forbid

from iiif-prezi3.

digitaldogsbody avatar digitaldogsbody commented on July 16, 2024

The whole schema file is here: https://github.com/IIIF/presentation-validator/blob/2f9f7e4ec5f671ebcdf8b2eef76cae2a7d50f26b/schema/iiif_3_0.json

And the command we are using is: datamodel-codegen --input iiif_3_0.json --input-file-type jsonschema --use-default --remove-special-field-name-prefix --strict-nullable --base-class .base.Base --output skeleton.py

from iiif-prezi3.

digitaldogsbody avatar digitaldogsbody commented on July 16, 2024

datamodel-code-generator 0.17.0 is out (https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.17.0) which contains the above fix - so we should update to that and test that it's resolved the LngString issue

from iiif-prezi3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.